version 1.24, 2004/06/22 10:33:53
|
version 1.32, 2004/09/20 09:00:58
|
Line 13
|
Line 13
|
* rogo |
* rogo |
*/ |
*/ |
|
|
|
|
import java.sql.*; |
import java.sql.*; |
import java.text.DateFormat; |
import java.text.DateFormat; |
import java.text.ParseException; |
import java.text.ParseException; |
Line 87 public class DBBean
|
Line 86 public class DBBean
|
DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("com.mysql.jdbc.Driver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("com.mysql.jdbc.Driver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance()); |
|
DriverManager.registerDriver((Driver) Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("acs.jdbc.Driver").newInstance()); |
DriverManager.registerDriver((Driver) Class.forName("acs.jdbc.Driver").newInstance()); |
|
|
// wait a maximum of 10 seconds when attempting to establish a connection |
// wait a maximum of 10 seconds when attempting to establish a connection |
Line 199 public class DBBean
|
Line 199 public class DBBean
|
// Connect to the database |
// Connect to the database |
connection = DriverManager.getConnection(url, prop); |
connection = DriverManager.getConnection(url, prop); |
System.out.println("odbc with properties inited"); |
System.out.println("odbc with properties inited"); |
} |
} else |
else |
|
connection = DriverManager.getConnection(url, user, passwd); |
connection = DriverManager.getConnection(url, user, passwd); |
connectionPool.put(url, new ConnectionPool(url, user, passwd, connection)); |
connectionPool.put(url, new ConnectionPool(url, user, passwd, connection)); |
|
|
Line 614 public class DBBean
|
Line 613 public class DBBean
|
// container fields |
// container fields |
try |
try |
{ |
{ |
tableRow.addElement(new Double(resultSet.getDouble(i))); |
Double value =new Double(resultSet.getDouble(i)); |
m_columnClasses.addElement(Double.class); |
|
|
|
|
// tableRow.addElement(new Double(resultSet.getDouble(i))); |
|
String tVal =value.toString(); |
|
tVal = tVal.substring(tVal.indexOf('.')+1); |
|
boolean checkMe = tVal.length()==1&&tVal.equals("0"); |
|
// System.out.println("check was"+checkMe+" "+tVal); |
|
if(checkMe) |
|
tableRow.addElement(new Integer(value.intValue())); |
|
else |
|
tableRow.addElement(value); |
|
|
} catch (Exception e) |
} catch (Exception e) |
{ |
{ |
Line 710 public class DBBean
|
Line 719 public class DBBean
|
|
|
if (!connection.isClosed()) |
if (!connection.isClosed()) |
stm = connection.createStatement(); |
stm = connection.createStatement(); |
else { |
else |
|
{ |
|
|
try |
try |
{ |
{ |
Line 725 public class DBBean
|
Line 734 public class DBBean
|
} |
} |
stm.setMaxRows(numberOfHits); |
stm.setMaxRows(numberOfHits); |
long time = System.currentTimeMillis(); |
long time = System.currentTimeMillis(); |
try { |
try |
|
{ |
stm.execute(query); |
stm.execute(query); |
long time2 = System.currentTimeMillis(); |
long time2 = System.currentTimeMillis(); |
|
|
Line 735 public class DBBean
|
Line 745 public class DBBean
|
result = stm.getResultSet(); |
result = stm.getResultSet(); |
// System.out.println(result+" "+stm.getUpdateCount()); |
// System.out.println(result+" "+stm.getUpdateCount()); |
metaData = result.getMetaData(); |
metaData = result.getMetaData(); |
} 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"); |
Line 1347 public class DBBean
|
Line 1358 public class DBBean
|
// container fields |
// container fields |
try |
try |
{ |
{ |
tableRow.addElement(new Double(resultSet.getDouble(i))); |
Double value =new Double(resultSet.getDouble(i)); |
|
|
|
|
|
// tableRow.addElement(new Double(resultSet.getDouble(i))); |
|
String tVal =value.toString(); |
|
tVal = tVal.substring(tVal.indexOf('.')+1); |
|
boolean checkMe = tVal.length()==1&&tVal.equals("0"); |
|
// System.out.println("check was"+checkMe+" "+tVal); |
|
if(checkMe) |
|
tableRow.addElement(new Integer(value.intValue())); |
|
else |
|
tableRow.addElement(value); |
|
|
// m_columnClasses.addElement(Integer.class); |
// m_columnClasses.addElement(Integer.class); |
|
|
} catch (Exception e) |
} catch (Exception e) |
Line 1415 public class DBBean
|
Line 1438 public class DBBean
|
|
|
} else |
} else |
tableRow.addElement(null); |
tableRow.addElement(null); |
} |
} else |
else |
|
{ |
{ |
if(url.toLowerCase().indexOf("odbc")>=0) |
if(url.toLowerCase().indexOf("odbc")>=0) |
{ |
{ |
Line 1507 public class DBBean
|
Line 1529 public class DBBean
|
ResultSet result = this.result; |
ResultSet result = this.result; |
String subQuery = query.substring(query.lastIndexOf(table)+table.length()+1); |
String subQuery = query.substring(query.lastIndexOf(table)+table.length()+1); |
System.out.println("subQuery "+subQuery); |
System.out.println("subQuery "+subQuery); |
makeQuery("select "+id+" from "+getQC()+table+getQC()+subQuery,numHits ); |
makeQuery("select " + id + " from " + getQC() + table + getQC() + subQuery+"order by "+id, numHits); |
while(true) |
while(true) |
{ |
{ |
Vector vec = getNextRow(); |
Vector vec = getNextRow(); |
Line 1534 public class DBBean
|
Line 1556 public class DBBean
|
{ |
{ |
useNormanToUnicodeMapper = b; |
useNormanToUnicodeMapper = b; |
} |
} |
|
/** |
|
* |
|
*/ |
|
protected void closeAllConnections() |
|
{ |
|
Enumeration enumeration = connectionPool.elements(); |
|
while(enumeration.hasMoreElements()) |
|
{ |
|
ConnectionPool conPol =(ConnectionPool)enumeration.nextElement(); |
|
try |
|
{ |
|
System.out.println(conPol); |
|
conPol.con.close(); |
|
} catch (SQLException e) |
|
{ |
|
// TODO Auto-generated catch block |
|
e.printStackTrace(); |
|
} |
|
} |
|
|
|
} |
|
/** |
|
* @param indexField |
|
*/ |
|
public String getColumnType(String indexField) throws SQLException |
|
{ |
|
Vector names=getColumnNames(); |
|
for (int i = 0; i < names.size(); i++) |
|
{ |
|
if(names.get(i).toString().equals(indexField)) |
|
{ |
|
System .out.println("found field "+names.get(i)+" "+metaData.getColumnTypeName(i+1)); |
|
return metaData.getColumnTypeName(i+1); |
|
|
|
} |
|
} |
|
return ""; |
|
} |
|
|
} |
} |
|
|