我正在使用以下代码将用户添加到我的数据库中名为 USERS 的表中,连接是正确的,因为我尝试了其他查询并且它们有效,我在 Oracle 本身中尝试了这个查询并且它有效,我只是有java中的查询问题,主要是因为SPACE和语法,这个有什么问题?
try
{
stmt=conn.createStatement();
//query="INSERT INTO Users (user_id,username,password,first_name,last_name) " + " VALUES (seq_users.nextval,'"+usernameCreateField.getText()+"','"+new String(passwordCreateField.getPassword())+"','"+firstnameCreateField.getText()+"','"+lastnameCreateField.getText()+"') ";
query="INSERT INTO Users (user_id,username,password,first_name,last_name) " +" VALUES (seq_users.nextval,'test','test','test','test') ";
rset=stmt.executeQuery(query);
}
catch(SQLException | NumberFormatException e)
{
System.out.println("result error, " +e.getMessage());
}
finally
{
try
{
rset.close();
stmt.close();
}
catch(Exception e)
{
System.out.println("Error in closing "+e.getMessage());
}
}