我正在使用开放式办公室数据库3.3作为我的数据库。 我成功地建立了这一联系,但在试图回答提问时却出现了错误:
public class openofficeupdate {
String databaseurl="C:\Users\RAVITEJA\Documents\BluetoothExchangeFolder\salesforce.odb";
openofficeupdate() throws ClassNotFoundException, SQLException{
System.out.println("Entered into constructor");
Connection connection=null;
Statement statement=null;
try{
Class c=openofficeclass();
System.out.println("Class name set");
Connection cntn=createConnection(databaseurl);
connection=cntn;
System.out.println("connection created");
Statement stmt=createStatement(cntn);
statement=stmt;
System.out.println("Statement created");
executeQueries(stmt);
System.out.println("Query executed");
closeStatement(stmt);
System.out.println("Statement closed");
closeConnection(cntn);
System.out.println("Connection closed");
}catch(Exception e){
System.out.println(e);
closeStatement(statement);
System.out.println("Statement closed");
closeConnection(connection);
System.out.println("Connection closed");
}
}
public static void main(String args[]) throws ClassNotFoundException, SQLException{
new openofficeupdate();
}
private Class openofficeclass() throws ClassNotFoundException {
return Class.forName("org.hsqldb.jdbcDriver");
}
private Connection createConnection(String databaseurl) throws SQLException{
return DriverManager.getConnection("jdbc:hsqldb:file:" +databaseurl);
}
private Statement createStatement(Connection cntn) throws SQLException{
return cntn.createStatement();
}
private void closeStatement(Statement stmt) throws SQLException{
stmt.close();
}
private void closeConnection(Connection cntn) throws SQLException{
cntn.close();
}
private void executeQueries(Statement stmt) throws SQLException{
System.out.println("Going to execute query");
//int status=stmt.executeUpdate("insert into Mobiles(Mobile ID,Employee ID,Start_Track_Time,Stop_Track_Time) values(987654321,198,09:30:00,10:30:00)");
ResultSet rs=stmt.executeQuery("select * from Mobiles;");
while(rs.next()){
System.out.println("Inside row "+rs.getRowId(1));
}
System.out.println("Query executed with status ");
}
}
我将hsqldb.jar作为我的班子。 以上编码的产出显示:......
Entered into constructor
Class name set
connection created
Statement created
Going to execute query
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MOBILES
Statement closed
Connection closed
这有什么错误?