Help with java retrieving from Ms Access
i have encountered problem when trying to retrieve the score from my database and there seems to be something wrong with my sql statement. can someone help me check the codes? the table is named Table1 and consist of the column number, NameParticipant and Score.
Code java:
private void results()
{
try
{
if(rs == null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:tips");
String sql = "Select NameParticipant from Table1 ORDER BY Score DESC LIMIT 1 ";
Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = statement.executeQuery(sql);
addtolabel();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void addtolabel()
{
try{
label91.setText(rs.getString("tips"));
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
Re: Help with java retrieving from Ms Access
Quote:
and there seems to be something wrong with my sql statement
What do you mean something wrong? Is an exception thrown? If so, post the exception...what does it tell you?