Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT Text(CSV)
Evaluation hxtt text driver sql support
frank
2006-05-23 08:20:39.0
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
Re:Evaluation hxtt text driver sql support
HXTT Support
2006-05-23 08:40:46.0
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();
}
}
}

Re:Re:Evaluation hxtt text driver sql support
frank
2006-05-23 08:49:24.0
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

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap