Hi,
I'm trying to run a basic query which causes a NullPointerException somewhere within the HXTT JDBC code. I can run the same query against the same database using the Java SE's built-in ODBC JDBC driver without a problem.
Here is the code:
String url = "jdbc:dbf:/f:/pathToDBC/";
Properties properties = new Properties();
properties.setProperty("user", "patrick");
properties.setProperty("password", "");
properties.setProperty("lockType", "VFP");
properties.setProperty("versionNumber", "30");
properties.setProperty("OtherExtensions", "true");
properties.setProperty("MissingMemoFile", "ignore");
properties.setProperty("loadIndices", "false");
properties.setProperty("Default Index Suffix", "cdx");
cn = DriverManager.getConnection(url, properties);
cn.setAutoCommit(false);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -180);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int dom = cal.get(Calendar.DAY_OF_MONTH);
int i = 1;
StringBuffer sql = new StringBuffer();
sql.append(" select ");
sql.append(" so.orderkey, "); int SO_PK = i++;
sql.append(" soil.orditmkey, "); int SO_IL_PK = i++;
sql.append(" soil.idcode, "); int SO_IL_ITEM_CODE = i++;
sql.delete(sql.length() - 2, sql.length());
sql.append(" from ");
sql.append(" arorditm as soil ");
sql.append(" inner join arord as so ");
sql.append(" on soil.orderkey = so.orderkey ");
sql.append(" where ");
sql.append(" so.lastupdate >= ");
sql.append(" {ts '");
sql.append(year);
sql.append("-");
if (month < 10) sql.append("0");
sql.append(month);
sql.append("-");
if (dom < 10) sql.append("0");
sql.append(dom);
sql.append(" 00:00:00.000");
sql.append("'}");
sql.append(";");
log.debug(sql);
Statement statement = null;
ResultSet rs = null;
try
{
statement = cnDSYS.createStatement();
rs = statement.executeQuery(sql.toString());
while (rs.next())
{
Long soPK = rs.getLong(SO_PK);
}
rs.close();
rs = null;
statement.close();
statement = null;
cn.commit();
}
catch (SQLException e)
{
e.printStackTrace();
try { cn.rollback(); } catch (SQLException sqle) {}
}
finally
{
if (statement != null) try { statement.close(); } catch (SQLException e) {}
if (rs != null) try { rs.close(); } catch (SQLException e) {}
}
try
{
cn.close();
}
catch (SQLException e)
{}
Here is the result:
2007-01-16 12:07:43,245 DEBUG [SyncSalesOrder] select so.orderkey, soil.orditmkey, soil.idcode from arorditm as soil inner join arord as so on soil.orderkey = so.orderkey where so.lastupdate >= {ts '2006-07-20 00:00:00.000'};
java.sql.SQLException: java.lang.NullPointerException
at com.hxtt.sql.dbf.i.do(Unknown Source)
at com.hxtt.sql.ce.a(Unknown Source)
at com.hxtt.sql.aw.if(Unknown Source)
at com.hxtt.sql.dc.a(Unknown Source)
at com.hxtt.sql.dc.a(Unknown Source)
at com.hxtt.sql.dc.a(Unknown Source)
at com.hxtt.sql.bm.a(Unknown Source)
at com.hxtt.sql.bm.a(Unknown Source)
at com.hxtt.sql.ag.a(Unknown Source)
at com.hxtt.sql.ag.a(Unknown Source)
at com.hxtt.sql.ag.executeQuery(Unknown Source)
at com.vanbelle.utility.syncimport.SyncSalesOrder.sync(SyncSalesOrder.java:
at com.vanbelle.utility.syncimport.Application.main(Application.java:91)
at com.hxtt.global.SQLState.SQLException(Unknown Source)
at com.hxtt.sql.bm.a(Unknown Source)
at com.hxtt.sql.ag.a(Unknown Source)
at com.hxtt.sql.ag.a(Unknown Source)
at com.hxtt.sql.ag.executeQuery(Unknown Source)
at com.vanbelle.utility.syncimport.SyncSalesOrder.sync(SyncSalesOrder.java:58)
at com.vanbelle.utility.syncimport.Application.main(Application.java:91)
|
Hi,
Accord your sql, i create two simple and insert few records ,
then run this sql, it works fine.
So, please download the latest HXTT DBF JDBC Package and retry, if it doesn't work normal, please compress your file and send it to us.
|
Strange,
On a whim I changed one of the connection properties to:
properties.setProperty("loadIndices", "true");
and now it works.
|
Recurred your issue. You can download a new version after 24 hours. Thanks.
|