谁帮我看下代码哪里错啦老提示java.sql.SQLSyntaxErrorException: ORA-00984: 列在此处不允许
publicclasszuoyeDUBtil{publicstaticvoidmain(String[]args){try{Connectionconn=DBUTil.g...
public class zuoyeDUBtil {
public static void main(String[] args) {
try {
Connection conn=DBUTil.getConnection();
//获取用户输入
Scanner scan=new Scanner(System.in);
System.out.println("输入用户名");
String str=scan.nextLine();
System.out.println("输入密码");
String str2=scan.nextLine();
System.out.println("输入工资");
int money=scan.nextInt();
Statement state=conn.createStatement();
String sql1="" +
"CREATE SEQUENCE userinfo5 " +
"START WITH 1 " +
"INCREMENT BY 1 ";
state.execute(sql1);
System.out.println("创建完毕");
String sql2="SELECT userinfo5.NEXTVAL FROM DUAL ";
ResultSet rs= state.executeQuery(sql2);
String sql="INSERT INTO userinfo " +
"(id,username,password,money) " +
"VALUES " +
"(userinfo3.NAXTVAL,'str','str2',money) ";
int n=state.executeUpdate(sql);
if(n>0){
System.out.println("插入成功");
}else{
System.out.println("插入失败");
}
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
! 展开
public static void main(String[] args) {
try {
Connection conn=DBUTil.getConnection();
//获取用户输入
Scanner scan=new Scanner(System.in);
System.out.println("输入用户名");
String str=scan.nextLine();
System.out.println("输入密码");
String str2=scan.nextLine();
System.out.println("输入工资");
int money=scan.nextInt();
Statement state=conn.createStatement();
String sql1="" +
"CREATE SEQUENCE userinfo5 " +
"START WITH 1 " +
"INCREMENT BY 1 ";
state.execute(sql1);
System.out.println("创建完毕");
String sql2="SELECT userinfo5.NEXTVAL FROM DUAL ";
ResultSet rs= state.executeQuery(sql2);
String sql="INSERT INTO userinfo " +
"(id,username,password,money) " +
"VALUES " +
"(userinfo3.NAXTVAL,'str','str2',money) ";
int n=state.executeUpdate(sql);
if(n>0){
System.out.println("插入成功");
}else{
System.out.println("插入失败");
}
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
! 展开
1个回答
展开全部
String sql="INSERT INTO userinfo " +
"(id,username,password,money) " +
"VALUES " +
"(userinfo3.NAXTVAL,'str','str2',money) ";
前面定义的 命名是 CREATE SEQUENCE userinfo5
前面是 5,后面的 怎么用3??
"(id,username,password,money) " +
"VALUES " +
"(userinfo3.NAXTVAL,'str','str2',money) ";
前面定义的 命名是 CREATE SEQUENCE userinfo5
前面是 5,后面的 怎么用3??
更多追问追答
追问
这是我刚才写错啦 不是这个问题
追答
把你的建表语句拿出来看看 就是 userinfo 那张表
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询