当我尝试使用 ucanaccess 访问现有数据库中的插入时,它显示了一个像这样的平均错误:
Exception in thread "main" net.ucanaccess.jdbc.UcanaccessSQLException: user lacks privilege or object not found: L
at net.ucanaccess.jdbc.UcanaccessStatement.executeQuery(UcanaccessStatement.java:202)
at sequence.FrequencyAnalyser.FrequencyAnalyser(FrequencyAnalyser.java:130)
at sequence.Sequence.main(Sequence.java:57)
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: L
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)
at net.ucanaccess.jdbc.UcanaccessStatement.executeQuery(UcanaccessStatement.java:199)
... 2 more
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: L
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readSimpleColumnName(Unknown Source)
at org.hsqldb.ParserDQL.readSimpleColumnNames(Unknown Source)
at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 5 more
Java Result: 1
我的编码部分
频率分析仪:
try
{
System.out.println("Good here");
String state="INSERT INTO sequences (A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y,GENE) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
st = odbc.con.createStatement();
ps = (PreparedStatement) st.executeQuery(state);
ps.setString(1, (String.valueOf(probability[0])));
数据库代码:
package sequence;
import java.sql.*;
public class OdbcAccessConnection {
Statement state;
Connection con = null;
public OdbcAccessConnection() throws SQLException, ClassNotFoundException
{
try
{
System.out.println("Entered");
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Connect with a URL string
System.out.println("Database connection started...");
con = DriverManager.getConnection("jdbc:ucanaccess://F:\\Thiyaga\\Database\\sequences.accdb");
System.out.println("Hello satarted");
state = con.createStatement();
System.out.println("Connection ok.");
/**
*
* @param a
* @param c
* @param d
* @param e
* @param f
* @param g
* @param i
* @param k
* @param l
* @param m
* @param n
* @param p
* @param q
* @param r
* @param s
* @param t
* @param v
* @param y
*/
}
catch (SQLException e)
{
System.err.println("Exception: " + e.getMessage());
}
}
}
实际上已经建立了连接!!