Java 如何修复语法错误或“;(“什么;?
现在我使用postgreSQL并制作库存管理程序。Java 如何修复语法错误或“;(“什么;?,java,postgresql,jdbc,ddl,Java,Postgresql,Jdbc,Ddl,现在我使用postgreSQL并制作库存管理程序。 当我制作表格时,发生了错误。 我的代码是这样的 import java.sql.Connection; import java.sql.Statement; public class Create_Table { public static void main(String[] args) { Connection connection = null; Statement state
当我制作表格时,发生了错误。
我的代码是这样的
import java.sql.Connection;
import java.sql.Statement;
public class Create_Table {
public static void main(String[] args) {
Connection connection = null;
Statement statement = null;
ConnectDB obj_ConnectDB = new ConnectDB();
connection = obj_ConnectDB.get_connection();
try {
String query = "CREATE TABLE IF NOT EXISTS stockmanagement ("
+ "ID SERIAL primary key, "
+ "Name varchar(20), "
+ "Unit_price numeric(15,1), "
+ "Qty INT(20),"
+ "Imported_Date Date,"
+ ")";
statement = connection.createStatement();
statement.executeUpdate(query);
System.out.println("finished");
} catch (Exception e) {
e.printStackTrace();
}
}
}
错误的内容如下。错误:语法错误,”(“
如何修复此错误?
如果您知道这个解决方案,可以教我吗?字符串中有两个错误
String query = "CREATE TABLE IF NOT EXISTS stockmanagement ("
+ "ID SERIAL primary key, "
+ "Name varchar(20), "
+ "Unit_price numeric(15,1), "
+ "Qty INT,"
+ "Imported_Date Date"
+ ")";
字符串中有两个错误
String query = "CREATE TABLE IF NOT EXISTS stockmanagement ("
+ "ID SERIAL primary key, "
+ "Name varchar(20), "
+ "Unit_price numeric(15,1), "
+ "Qty INT,"
+ "Imported_Date Date"
+ ")";
你在哪里发现
int(20)
在Postgres中有效?哦,这是我的错误。谢谢你的评论!祝你愉快!XD你在哪里发现int(20)
在Postgres中有效?哦,这是我的错误。谢谢你的评论!祝你愉快!XDI认为int(20)
可能应该用BIGINT
代替INT
,假设20是用来表示数字的。谢谢!!因为你我解决了这个问题!祝你愉快!XDI thinkINT(20)
可能应该替换为BIGINT
而不是INT
,假设20是用来表示数字的。谢谢!!因为你我解决了这个问题!祝你愉快!XD