java - net.ucanaccess.jdbc.UcanaccessSQLException: Column not found: 0 -
i new ucanaccess
package checktpsystemdatabase; import java.sql.*; public class checktpsystemdatabase { public static void main(string[] args) throws sqlexception { seek { connection con = drivermanager.getconnection("jdbc:ucanaccess://d:/java/transactionprocessingsystem/src/transactionprocessingsystem/resources/tpsystem.accdb"); statement stmt = con.createstatement(); resultset rs = stmt.executequery("select * product"); while (rs.next()) { system.out.println(rs.getint(0) + "\t" + rs.getstring(1) + "\t" + rs.getstring(2)); } rs.close(); } grab (sqlexception e) { system.out.println(e); } } }
when execute code, showing "net.ucanaccess.jdbc.ucanaccesssqlexception: column not found: 0"
. please help me!
you seeing error because numeric index values jdbc resultset start 1, not 0. or, in "retrieving column values rows" section of java tutorial here:
the resultset interface declares getter methods (for example, getboolean , getlong) retrieving column values current row. can retrieve values using either index number of column or alias or name of column. column index more efficient. columns numbered 1
(emphasis mine.)
java jdbc ucanaccess
No comments:
Post a Comment