我正在尝试使用 jdbc 在 dbf 表上进行插入,但每次执行系统时都会给我这个错误:
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Syntax error.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
at addProduct.test.main(test.java:29)
这是代码:
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connString="jdbc:odbc:Driver={Microsoft Visual FoxPro Driver};SourceDB=C:\\RestBar\\DBC;SourceType=DBF";//DeafultDir indicates the location of the db
Connection connection=DriverManager.getConnection(connString);
Statement query = connection.createStatement();
ResultSet result;
String sql="INSERT INTO CUENTAS (NUM_CTA, NUB_CTA, CAJ_CTA, FEC_CTA, HOR_CTA, " +
"OPE_CTA, MES_CTA, NOM_CTA, UBI_CTA, PER_CTA, ACU_CTA, USU_CTA, KDI_CTA) " +
"VALUES('0000001', SELECT DES_MEZ FROM MESAS WHERE COD_MEZ = 'T01', '01', " +
"'2013/07/18', '16:50:33', 0,'002', SELECT DES_MES FROM MESEROS WHERE COD_MES = '002'," +
" 'T01', '2',0.00, 01, 0.00)";
query.execute(sql);
}