1:无效的SQL URL:
//将获取的参数插入数据库
Connection
conn=null;
PreparedStatement stat=null;
try {
Class.forName("oracle.jdbc.OracleDriver");
try {
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl",
"system","oracle");
String
sql="insert into t_emp values(t_emp_id_seq.nextval,?,?,?)";
stat=conn.prepareStatement(sql);
stat.setString(1,name);
stat.setDouble(2,salary);
stat.setInt(3,age);
stat.executeUpdate();
out.println("添加完成!");
out.close();
错误的原因:thin的后面有: ,很容易被忽略,以后做项目要注意
2:第二个错误是java.sql.SQLException: Listener refused the connection with
the following error:
这个是sid错误的原因,本来是orcl,被我写成了xe,没有修改,使用了默认的了,以后做项目是应该留心。
相关文章:
-
2021-08-09
-
2021-06-15
-
2022-12-23
-
2022-12-23
-
2021-10-17
-
2021-04-14
-
2021-10-07
-
2022-12-23
猜你喜欢
-
2021-12-30
-
2021-06-17
-
2021-09-20
-
2022-12-23
-
2021-05-09
-
2022-12-23
-
2022-12-23
相关资源
-
下载
2023-02-16
-
下载
2023-04-07
-
下载
2021-06-29