English 中文(简体)
公开办公数据库的查询
原标题:Queries in open office database

我正在使用开放式办公室数据库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

这有什么错误?

问题回答

当你重新与数据库连接时,你作为没有特权进入数据库中某些实体的用户重新这样做。 您需要为您与拥有适当特权的用户建立联系提供便利。 根据这一说法,你想要的用户名称是SA。

数据库开发商可能惊讶地获悉该开放办公室。 基地已经有一个用户账户。 该用户账户(名称为SA)。

Use the setClientInfo(, 链接反对将用户名称定为“SA”。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签