Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

COUNT field incorrect: error help

807599Mar 23 2007 — edited Mar 23 2007
Hi, im quite new to java and im building an application to connect to a database and perfom various searches. the program displays the database data by means of a table.

I can imagine ive done something wrong with the prepaired statements but i cant see what, Any suggestions would be very helpful. Here is the method that i have a problem with:

public void test()
{


Vector columnNames = new Vector();
Vector data = new Vector();

{
try
{

// Connect to the Database
String url = "jdbc:odbc:ris1851";
Connection con;
//String driver = "sun.jdbc.odbc.JdbcOdbcDriver";

Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
String querySEARCH = "SELECT * FROM RIS51 WHERE SURNAME = ? order by age";
String SEARCH = txtUser.getText();

con = DriverManager.getConnection(url);
PreparedStatement search = con.prepareStatement(querySEARCH);

Statement stmt = con.createStatement();
ResultSet rs = search.executeQuery();


ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();

// Get column names

for (int i = 0; i < columns; i++)
{

columnNames.addElement( md.getColumnName(i) );
}

//Get row data

while (rs.next())
{
Vector row = new Vector(columns);

for (int i = 0; i < columns; i++)
{
row.addElement( rs.getObject(i) );
}


data.addElement( row );
}

rs.close();
search.close();
}
catch(Exception e)
{
System.out.println(e );
}

when i call the method i get:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2007
Added on Mar 23 2007
4 comments
367 views