R
redgambit
Hello,
I have a program that queries an MS Access DB then fills in the
approperate info in the program. I'm using the standard jdbc.odbc
bridge right now. And it is very slow. I was wondering if there is
anyway to speed it up.
String OComp = dbu.get("Company", "Database", "Zip", "'" + zipcode + "'
AND company='" + Company + "'");
....
public String get(String col, String table, String v1, String ref) {
String field = col;
sql = "SELECT "+ col +" FROM "+ table +" WHERE "+v1+"="+ref;
String comp = this.submit(sql, field);
return comp;
}
....
public String submit(String sql, String field) {
String out = new String();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException cnfe) { // driver not found
System.err.println("Unable to load database driver");
System.err.println("Details : " + cnfe);
}
try {
String url = "jdbcdbcatabase";
Connection db_connection =
DriverManager.getConnection(url);
Statement stmt = db_connection.createStatement();
ResultSet result = stmt.executeQuery(sql);
if (result.next());
out = result.getString(field);
} catch (SQLException c) {
System.err.println(c);
}
return out;
I would like to keep my code as reusable as possible.
Thank you so much.
I have a program that queries an MS Access DB then fills in the
approperate info in the program. I'm using the standard jdbc.odbc
bridge right now. And it is very slow. I was wondering if there is
anyway to speed it up.
String OComp = dbu.get("Company", "Database", "Zip", "'" + zipcode + "'
AND company='" + Company + "'");
....
public String get(String col, String table, String v1, String ref) {
String field = col;
sql = "SELECT "+ col +" FROM "+ table +" WHERE "+v1+"="+ref;
String comp = this.submit(sql, field);
return comp;
}
....
public String submit(String sql, String field) {
String out = new String();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException cnfe) { // driver not found
System.err.println("Unable to load database driver");
System.err.println("Details : " + cnfe);
}
try {
String url = "jdbcdbcatabase";
Connection db_connection =
DriverManager.getConnection(url);
Statement stmt = db_connection.createStatement();
ResultSet result = stmt.executeQuery(sql);
if (result.next());
out = result.getString(field);
} catch (SQLException c) {
System.err.println(c);
}
return out;
I would like to keep my code as reusable as possible.
Thank you so much.