我是java.i的新手,我想使用java.i将值插入到数据库(pgadmin)中,但每次使用它都会给我一个错误。问题似乎出在INSERT语句中。我
public void obtaindata(){
System.out.println("enter the data you want to insert");
System.out.print("Product Name");
String productname=input.nextLine();
System.out.println("Product Price");
Double productprice=input.nextDouble();
Database2 database2=new Database2();
database2.insertRecord(productname,productprice);
public void insertRecord(String productname,Double productprice){
try{
//using preparedstatement
PreparedStatement stmt = con.prepareStatement("INSERT INTO
public.product(product_id,product_name,product_price)" +
"VALUES (?,?,?);");
stmt.setString(1,"nextval('productid_sequence')");
stmt.setString(2,productname);
stmt.setDouble(3,productprice);
stmt.executeUpdate();
stmt.close();
}catch(SQLException e){
e.printStackTrace();
}
}