Abstracted the HTTP server with TCP Network classes and added an SSDP service

This commit is contained in:
Ziver Koc 2010-01-31 18:10:00 +00:00
parent b3ad292ff9
commit 45f514fc27
25 changed files with 1645 additions and 688 deletions

View file

@ -21,6 +21,7 @@ public class MySQLConnection {
public MySQLConnection(String url, String db, String user, String password)
throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException{
Class.forName ("com.mysql.jdbc.Driver").newInstance();
DriverManager.setLoginTimeout(10);
conn = DriverManager.getConnection ("jdbc:mysql://"+url+"/"+db, user, password);
}
@ -48,8 +49,11 @@ public class MySQLConnection {
Statement s = conn.createStatement ();
s.executeQuery(sql);
ResultSet result = s.getResultSet();
if(result.next())
return result.getString(0);
if(result.next()){
String tmp = result.getString(1);
result.close();
return tmp;
}
return null;
}
@ -66,6 +70,22 @@ public class MySQLConnection {
return ret;
}
/**
* @return the last inserted id or -1 if there was an error
* @throws SQLException
*/
public int getLastInsertID() throws SQLException{
Statement s = conn.createStatement ();
s.executeQuery("SELECT LAST_INSERT_ID()");
ResultSet result = s.getResultSet();
if(result.next()){
int tmp = result.getInt(1);
result.close();
return tmp;
}
return -1;
}
/**
* Runs a Prepared Statement.<br>
* <b>NOTE:</b> Don't forget to close the PreparedStatement or it can lead to memory leak