我創建嵌入式Derby數據庫,它給我error.although我在哪個表REST創建Java的嵌入式Derby表/視圖
java.sql.SQLSyntaxErrorException: Table/View 'REST' does not exist.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
這裏是java類APP模式:
public class Main
{
private static String dbURL = "jdbc:derby:tes;create=true";
private static String tableName = "REST";
// jdbc Connection
private static Connection conn = null;
private static Statement stmt = null;
public static void main(String[] args)
{
createConnection();
insertRestaurants(5, "LaVals", "Berkeley");
selectRestaurants();
shutdown();
}
private static void createConnection()
{
try
{
// System.setProperty("derby.system.home", "/Users/myuser/futbol");
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
//Get a connection
conn = DriverManager.getConnection(dbURL);
}
catch (Exception except)
{
except.printStackTrace();
}
}
private static void insertRestaurants(int id, String restName, String cityName)
{
try
{
stmt = conn.createStatement();
stmt.execute("insert into REST values (" +
id + ",'" + restName + "','" + cityName +"')");
stmt.close();
}
catch (SQLException sqlExcept)
{
sqlExcept.printStackTrace();
}
}
}
是的兩個都是大寫的,但仍然給我同樣的錯誤ALTHOGH它工作正常,當我右鍵單擊db並選擇執行命令。但在Java它給出了這個錯誤。 – 2011-02-15 18:49:20
表名在使用雙引號創建時僅區分大小寫。至少這就是標準要求的內容,據我所知德比符合標準 – 2011-02-15 18:56:13