English 中文(简体)
不应放弃...... 开放式办事处错误
原标题:Not Able to give previleges...Openoffice error
  • 时间:2009-12-24 08:38:04
  •  标签:
  • java

This is the code i had written to save the data into the openoffice database. but its giving error.i m not understanding y it is appearing.

package coop.data;
import java.sql.*;
/**
 *
 * @author spk
 */
public class Connectionsetting {

    private static Connection con;

    private static Statement sm;

    private static ResultSet rs;

    public static void close()
    {
        try
        {
            sm.close();
            con.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void connection() {
       String db_file_name_prefix = "/home/spk/Desktop/CooperHr/mydb.odb";
/*
    If required change the file name if you are working in windows os
  connection is in work

 */
        try {
            Class.forName("org.hsqldb.jdbcDriver");
            System.out.println("Driver Found");
            con=DriverManager.getConnection("jdbc:hsqldb:file"+db_file_name_prefix,"sa", "");
            System.out.println("Connection Eshtablished");
           // con.setAutoCommit(false);
            sm=con.createStatement();
       // sm = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
        } catch (Exception e) {
           e.printStackTrace();
        }
    }

    public static int executeupdate(String query) {
        //Execute & update block insert, update, delete statements
        int bool = 0;
        try {
                bool=sm.executeUpdate(query);
            } catch (Exception e) {
                e.printStackTrace();
            }

            return bool;
        }

    public ResultSet executeQuery(String query) {
        //Block Returns single resultset,,,sql statements such as sql select
        ResultSet rs=null;
        try {
            rs = sm.executeQuery(query);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rs;
    }
    public boolean checkTableStatus(String tblName) {
        String sql = "selec * from cat";

        ResultSet rs=null;

        boolean status = false;

        int i = 0;

        String allTableNames[] = new String[20];
        try {
            connection();
            rs = sm.executeQuery(sql);
            while (rs.next()) {

                allTableNames[i] = rs.getString(0);
                i++;

                if (allTableNames[i].equals(tblName)) {
                    status = true;
                    break;
                } else {
                    status = false;
                    break;
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return status;
    }
  public static void main(String []args)
    {
      String query,s1,s2,s3,s4,s5,s6,s7,s8;
       Connectionsetting cn=new Connectionsetting();
       cn.connection();
       s1="same";
       s2="sam";
       s3="923847";
       s4="sam";
       s5="sam";
       s6="sam";
       s7="sam";
       s8="R01";
       query="insert into Agency_Master values("+s1+","+s2+","+s3+","+s4+","+s5+","+s6+","+s7+","+s8+")";
       cn.executeupdate(query);



    }

}

This is the error..I m getting it when i trying to save the data into the database Can any one plz tell me where i m wrong.

谢谢。

a 包括:

Driver Found
Connection Eshtablished
java.sql.SQLException: user lacks privilege or object not found: AGENCY_MASTER
        at org.hsqldb.jdbc.Util.sqlException(Util.java:200)
        at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1805)
        at org.hsqldb.jdbc.JDBCStatement.executeUpdate(JDBCStatement.java:205)
        at coop.data.Connectionsetting.executeupdate(Connectionsetting.java:52)
        at coop.data.Connectionsetting.main(Connectionsetting.java:116)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: AGENCY_MASTER
        at org.hsqldb.Error.error(Error.java:76)
        at org.hsqldb.SchemaManager.getTable(SchemaManager.java:510)
        at org.hsqldb.ParserDQL.readTableName(ParserDQL.java:4367)
        at org.hsqldb.ParserDML.compileInsertStatement(ParserDML.java:64)
        at org.hsqldb.ParserCommand.compilePart(ParserCommand.java:132)
        at org.hsqldb.ParserCommand.compileStatements(ParserCommand.java:83)
        at org.hsqldb.Session.executeDirectStatement(Session.java:1037)
        at org.hsqldb.Session.execute(Session.java:865)
        at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1797)
        ... 3 more
BUILD SUCCESSFUL (total time: 0 seconds)
问题回答

• “你的关系......试图改变:

con=DriverManager.getConnection("jdbc:hsqldb:file"+db_file_name_prefix,"sa", "");

纽约总部

con=DriverManager.getConnection("jdbc:hsqldb:file:"+db_file_name_prefix+";ifexists=true","sa", "");

http://hsqldb.org/doc/guide/ch04.html

参看<代码>。 AGENCY_MASTER table isn t . 您试图执行<代码>update说明,而正如HSQLDB一样,可以找到<代码>。 AGENCY_MASTER table.

您可以核实与HSQLDB在客户/客户中是否存在表格:

java -cp hsqldb.jar org.hsqldb.util.DatabaseManagerSwing




相关问题
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 ...

热门标签