【发布时间】:2021-02-18 02:40:38
【问题描述】:
现在我使用 postgreSQL 并制作库存管理程序。
在我制作表格时,发生了错误。
我的代码是这样的!
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();
}
}
}
错误内容如下。error : syntax error, "("
如何解决此错误?
如果你知道这个解决方案,你能教我吗?
【问题讨论】:
-
你在哪里发现in the manual
int(20)在 Postgres 中有效? -
哦,这是我的错误。谢谢你的评论!祝你今天过得愉快! XD
标签: java postgresql jdbc ddl