version 1.17, 2004/04/30 10:56:06
|
version 1.18, 2004/05/06 11:39:42
|
Line 152 public class DBBean
|
Line 152 public class DBBean
|
ConnectionPool conPool = (ConnectionPool) connectionPool.get(url); |
ConnectionPool conPool = (ConnectionPool) connectionPool.get(url); |
if (conPool == null) |
if (conPool == null) |
{ |
{ |
connection = DriverManager.getConnection(url, user, passwd); |
createConnection(); |
connectionPool.put(url, new ConnectionPool(url, user, passwd, connection)); |
|
} else |
} else |
{ |
{ |
if (!conPool.user.equals(user) || !conPool.passwd.equals(passwd)) |
if (!conPool.user.equals(user) || !conPool.passwd.equals(passwd)) |
Line 167 public class DBBean
|
Line 167 public class DBBean
|
if (connection.isClosed()) |
if (connection.isClosed()) |
{ |
{ |
System.out.println("Made new connection!!!"); |
System.out.println("Made new connection!!!"); |
connection = DriverManager.getConnection(conPool.url, conPool.user, conPool.passwd); |
createConnection(); |
|
|
|
// connection = DriverManager.getConnection(conPool.url, conPool.user, conPool.passwd); |
conPool.con = connection; |
conPool.con = connection; |
} |
} |
} |
} |
if (url != "" && connection == null) |
if (url != "" && connection == null) |
connection = DriverManager.getConnection(url, user, passwd); |
createConnection(); |
|
//connection = DriverManager.getConnection(url, user, passwd); |
dbMetaData = connection.getMetaData(); |
dbMetaData = connection.getMetaData(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
if (quoteChar == null) |
if (quoteChar == null) |
Line 180 public class DBBean
|
Line 183 public class DBBean
|
|
|
return connection; |
return connection; |
} |
} |
|
private void createConnection() throws SQLException |
|
{ |
|
// setup the properties |
|
java.util.Properties prop = new java.util.Properties(); |
|
prop.put("charSet", "Cp1256"); |
|
prop.put("user", user); |
|
prop.put("password", passwd); |
|
System.out.println("url "+url); |
|
if(url.indexOf("odbc")>=0) |
|
{ |
|
// Connect to the database |
|
connection = DriverManager.getConnection(url, prop); |
|
System.out.println("odbc with properties inited"); |
|
} |
|
else |
|
connection = DriverManager.getConnection(url, user, passwd); |
|
connectionPool.put(url, new ConnectionPool(url, user, passwd, connection)); |
|
|
|
} |
/** |
/** |
* sets the connection of this DBBean to the database specified in the url |
* sets the connection of this DBBean to the database specified in the url |
* property |
* property |
Line 188 public class DBBean
|
Line 210 public class DBBean
|
{ |
{ |
this.url = url; |
this.url = url; |
if (url != "") |
if (url != "") |
connection = DriverManager.getConnection(url, user, passwd); |
//connection = DriverManager.getConnection(url, user, passwd); |
|
createConnection(); |
dbMetaData = connection.getMetaData(); |
dbMetaData = connection.getMetaData(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
if (quoteChar == null) |
if (quoteChar == null) |
Line 204 public class DBBean
|
Line 227 public class DBBean
|
this.passwd = passwd; |
this.passwd = passwd; |
this.url = url; |
this.url = url; |
if (url != "") |
if (url != "") |
connection = DriverManager.getConnection(url, user, passwd); |
createConnection(); |
|
// connection = DriverManager.getConnection(url, user, passwd); |
dbMetaData = connection.getMetaData(); |
dbMetaData = connection.getMetaData(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
quoteChar = dbMetaData.getIdentifierQuoteString(); |
if (quoteChar == null) |
if (quoteChar == null) |
Line 686 public class DBBean
|
Line 710 public class DBBean
|
stm.execute(query); |
stm.execute(query); |
} catch(Exception e) { |
} catch(Exception e) { |
// TODO remove |
// TODO remove |
if(FM2SQL.fmInstance!=null) |
// if(FM2SQL.fmInstance!=null) |
FM2SQL.showErrorDialog("Error caught!! \n Query was "+query+" \n","Debug Info"); |
// FM2SQL.showErrorDialog("Error caught!! \n Query was "+query+" \n","Debug Info"); |
} |
} |
long time2 = System.currentTimeMillis(); |
long time2 = System.currentTimeMillis(); |
|
|
Line 1345 public class DBBean
|
Line 1369 public class DBBean
|
if(url.toLowerCase().indexOf("odbc")>=0) |
if(url.toLowerCase().indexOf("odbc")>=0) |
{ |
{ |
byte[] val = resultSet.getBytes(i); |
byte[] val = resultSet.getBytes(i); |
tableRow.addElement((val==null) ? null:new String(val,"UTF-8")); |
for(int j=0;j<val.length;++j) |
|
System.out.println(Integer.toHexString(val[j])); |
|
tableRow.addElement((val==null) ? null:new String(val)); |
|
|
} else |
} else |
// byte[] val = resultSet.getBytes(i); |
// byte[] val = resultSet.getBytes(i); |