Update of /cvsroot/firebug/firebug/project/java/src/org/firebug/database
In directory sc8-pr-cvs1:/tmp/cvs-serv24954/src/org/firebug/database
Modified Files:
MysqlDBHandler.java
Log Message:
Fixed the database naming problem.
Index: MysqlDBHandler.java
===================================================================
RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/database/MysqlDBHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MysqlDBHandler.java 21 May 2003 23:51:51 -0000 1.7
--- MysqlDBHandler.java 18 Jul 2003 18:03:26 -0000 1.8
***************
*** 13,17 ****
/** FIXME: Move number_of_connections to the properties file.
*/
! private int number_of_connections = 10;
private LinkedList connectionqueue;
--- 13,17 ----
/** FIXME: Move number_of_connections to the properties file.
*/
! private int number_of_connections = 1;
private LinkedList connectionqueue;
***************
*** 29,32 ****
--- 29,34 ----
private String dbpass = null;
+ private String dbname = null;
+
/** Assumes that all connections are to the same
* database. This can be changed later by adding
***************
*** 45,59 ****
public MysqlDBHandler(String host, String port,
! String user, String passwd) {
setDebug();
setDBProperties(host,"",port,user,passwd);
set_c_pool(use_c_pool);
}
public MysqlDBHandler(String host, String port,
! String user, String passwd, boolean use_c_pool) {
setDebug();
setDBProperties(host,"",port,user,passwd);
set_c_pool(use_c_pool);
--- 47,64 ----
public MysqlDBHandler(String host, String port,
! String user, String passwd, String dbname) {
setDebug();
setDBProperties(host,"",port,user,passwd);
set_c_pool(use_c_pool);
+ this.dbname = dbname;
}
public MysqlDBHandler(String host, String port,
! String user, String passwd,
! String dbname, boolean use_c_pool) {
setDebug();
+ this.dbname = dbname;
setDBProperties(host,"",port,user,passwd);
set_c_pool(use_c_pool);
***************
*** 61,64 ****
--- 66,78 ----
+ public String get_dbname() {
+ return dbname;
+ }
+
+ public void set_dbname(String dbname) {
+ this.dbname = dbname;
+ System.out.println(dbname);
+ }
+
private void set_c_pool(boolean use_c_pool) {
***************
*** 104,108 ****
for (int i = 0; i < num_cons; i++) {
! connectionqueue.add(get_connection());
}
--- 118,123 ----
for (int i = 0; i < num_cons; i++) {
! /** Kludge: the database name needs to be passed in. */
! connectionqueue.add(get_connection(dbname));
}
***************
*** 142,150 ****
} catch (NoSuchElementException e) {
System.out.println("No more connections in queue. Fetch more.");
! connection = get_connection();
}
return connection;
} else {
! return get_connection();
}
--- 157,166 ----
} catch (NoSuchElementException e) {
System.out.println("No more connections in queue. Fetch more.");
! /** Kludge: the database name needs to be passed in. */
! connection = get_connection(dbname);
}
return connection;
} else {
! return get_connection(dbname);
}
***************
*** 176,180 ****
/** Handles the nuts and bolts of the connection.
*/
! private Connection get_connection() {
Connection connection = null;
--- 192,196 ----
/** Handles the nuts and bolts of the connection.
*/
! private Connection get_connection(String dbname) {
Connection connection = null;
***************
*** 201,205 ****
+ ":"
+ dbport
! + "/firebug?user="
+ dbuser
+ "&password="
--- 217,222 ----
+ ":"
+ dbport
! + "/"
! + dbname + "?user="
+ dbuser
+ "&password="
***************
*** 211,218 ****
try {
connection = DriverManager.getConnection(URL, dbuser, dbpass);
! if (debug)
System.out.println("Connection opened.");
! } catch (Exception e) {
System.out.println("We are not connecting here...");
e.printStackTrace();
}
--- 228,241 ----
try {
connection = DriverManager.getConnection(URL, dbuser, dbpass);
! if (debug) {
System.out.println("Connection opened.");
! }
! } catch (SQLException e) {
System.out.println("We are not connecting here...");
+ int error = e.getErrorCode();
+
+ if (error == 1049) {
+ System.out.println("Bad database specified");
+ }
e.printStackTrace();
}
|