出现异常(SQL 语法错误)。
数据库编程新手,到处寻找但似乎无法精确定位,
我知道执行该语句时遇到一些问题,因为错误日志告诉我错误行是 -
Statement stmt= con.prepareStatement(sql);
方法:
public static void createTable(String name) {
String url= "jdbc:derby://localhost:1527/newDB;create=true";
try (Connection con=DriverManager.getConnection(url)){
String sql="create table "+name+" (ID int, Name varchar(20)";
Statement stmt= con.prepareStatement(sql);
stmt.executeUpdate(sql);
System.out.println("Table Created");
}catch (SQLException e) {
System.out.println("Table creation interupted");
e.printStackTrace();
}
}
一直在尝试各种方法来编写这个,在主方法中,没有“create=true”, 与准备好的声明,但似乎没有任何作用。
提前致谢!!!
最佳答案
迂腐的编译器说你的Create Table SQL没有正确关闭,它应该是这样的:
create table some_table (ID int, Name varchar(20)
)
关于java - <EOF>创建 Derby 表时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56028884/