Hi,
I have one more issue that popped up during the evaluation of the driver:
Query:
oStmt = oDBCon.prepareStatement("SELECT CODE01, COUNT(*) FROM \"test1.txt\" GROUP BY CODE01");
java.sql.SQLException: Invalid column index: 3
at com.hxtt.global.SQLState.SQLException(Unknown Source)
at com.hxtt.sql.ci.new(Unknown Source)
at com.hxtt.sql.ci.getString(Unknown Source)
at be.landc.tests.frank.TestHXTT.run(TestHXTT.java:51)
at be.landc.tests.frank.TestHXTT.main(TestHXTT.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Same for an even simpler query:
oStmt = oDBCon.prepareStatement("SELECT COUNT(*) FROM \"test1.txt\"");
java.sql.SQLException: Invalid column index: 2
at com.hxtt.global.SQLState.SQLException(Unknown Source)
at com.hxtt.sql.ci.new(Unknown Source)
at com.hxtt.sql.ci.getString(Unknown Source)
at be.landc.tests.frank.TestHXTT.run(TestHXTT.java:51)
at be.landc.tests.frank.TestHXTT.main(TestHXTT.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Both errors occur when invoking:
oRS = oStmt.executeQuery();
What's happening ?
Thanks
Frank
|
It's normal because you're using a wrong column index for ResultSet.getString(...). I changed TestHXTT to show it:
import java.sql.*;
import java.util.Date;
import java.util.Properties;
public class TestHXTT {
public void run() throws Exception {
Connection oDBCon;
PreparedStatement oStmt;
Properties oProperties;
// Connect.
System.out.println(new Date() + " connecting");
oProperties = new Properties();
oProperties.put("_CSV_Header", "true");
oProperties.put("_CSV_Separator", "\t");
oProperties.put("_CSV_Quoter", "");
oProperties.put("charSet", "UTF-8");
Class.forName("com.hxtt.sql.text.TextDriver");
oDBCon = DriverManager.getConnection("jdbc:csv:/C:/Temp", oProperties);
// System.out.println(new Date() + " updating data");
// oStmt = oDBCon.prepareStatement("UPDATE \"test1.txt\" SET STREET_NAME = 'XXX' WHERE ID IN(232503, 232788, 232679)");
// oStmt = oDBCon.prepareStatement("UPDATE \"test1.txt\" SET STREET_NAME = 'XXX' WHERE ID IN(232503, 403859, 76195)");
// oStmt = oDBCon.prepareStatement("UPDATE \"test1.txt\" SET STREET_NAME = 'XXX' WHERE ID IN(232503, 403859, 76195)");
// System.out.println(oStmt.executeUpdate());
System.out.println(new Date() + " querying data");
// oStmt = oDBCon.prepareStatement("SELECT COUNT(*) FROM \"test1.txt\"");
oStmt = oDBCon.prepareStatement("SELECT CODE01, COUNT(*) FROM \"test1.txt\" GROUP BY CODE01");
ResultSet rs=oStmt.executeQuery();
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
for (int j = 1; j <= iNumCols; j++)
{
System.out.println(resultSetMetaData.getColumnLabel(j)
+ " " +
resultSetMetaData.getColumnTypeName(j));
}
rs.beforeFirst();
int ncount = 0;
Object colval;
while (rs.next()) {
ncount++;
for (int j = 1; j <= iNumCols; j++) {
colval = rs.getObject(j);
System.out.print(colval + (j }
System.out.println();
}
rs.close();
oStmt.close();
// Disconnect.
System.out.println(new Date() + " disconnecting");
oDBCon.close();
}
public static void main(String[] args) throws Exception {
try {
new TestHXTT().run();
}
catch (SQLException sqle) {
do {
System.out.println(sqle.getMessage());
System.out.println("Error Code:" + sqle.getErrorCode());
System.out.println("SQL State:" + sqle.getSQLState());
sqle.printStackTrace();
}
while ( (sqle = sqle.getNextException()) != null);
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
|
I'm sorry, completely stupid of me. I changed the query but forgot to change the access to the resultset. Must have been sleeping:)
Thanks,
Frank
|