public void getOutput() throws SQLException {
String sql = "SELECT * FROM Neuron";
rs = stmtN.executeQuery(sql);
while (rs.next()) {
String output = Integer.toString(rs.getInt(1))+": "+rs.getString(2);
System.out.println("Program output: "+output);
}
}
Program output: 0: there
Program output: 1: hello
Program output: 2: not
Program output: 3: this
Program output: 4: could
Program output: 5: be
Program output: 6: good
Program output: 7: I
Program output: 8: am
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC 驅動程式
管理
員] 函數順序錯誤
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:4089)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
at sun.jdbc.odbc.JdbcOdbc.SQLFetch(JdbcOdbc.java, Compiled Code)
at sun.jdbc.odbc.JdbcOdbcResultSet.next(JdbcOdbcResultSet.java,
Compiled
Code)
at JDBCTest.getOutput(NeuroSystem.java, Compiled Code)
and the program works fine about three out of four
and it can throws SQLException any time in the program...
and I can't find anything strange in the content of the database...
I definately needs some help...
I am using Access2000 and code for DB are as follows
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conN = DriverManager.getConnection("jdbc:odbc:Neuron","lib", "lib" );
stmtN = conN.createStatement();
conL = DriverManager.getConnection("jdbc:odbc:Link","lib", "lib" );
stmtL = conL.createStatement();
}
thank you for reading and answering my problem :)