Я использую базу данных открытого офиса 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
Что с этим не так?