当前位置:网站首页>Summary of common JDBC exceptions and error solutions

Summary of common JDBC exceptions and error solutions

2022-06-25 23:34:00 _ Qilixiang

Catalog

java.sql.SQLException:  Invalid column index

java.sql.SQLException: ORA-00911: Invalid character

java.sql.SQLException: ORA-01017: invalid username/password; login denied

java.sql.SQLException: Io abnormal :  The Network Adapter could not establish the connection at 

java.sql.SQLException: No sutiable driver found for jsbc:oracle1:thin:


java.sql.SQLException:  Invalid column index

1、sql List of ? The number of symbols does not match the number of variables provided :

for example :jdbcTemplate.update(sql, new Object[] {newState,oldState});

If sql There are 1 individual ? Number ,Object[] Yes 2 individual , You're going to report a mistake .

2、sql In the string ? The number is not written correctly

english ? And Chinese ? Sometimes it's hard to tell .

3、sql List of ? No '' All in all .

for example :sql="UPDATE abc SET abc.name='?' WHERE abc.id='?'";

hold '' Just remove it .

4, In this case select*from user where   info   like   %?%;  

Although this is sql Writing , But in jdbc It needs to be changed to select*from user where   info   like   ?;

Such as ps.setString(1,“%”+value+“%”);

java.sql.SQLException: ORA-00911: Invalid character

String sql = "insert into test1 values(1416270201,' Zhang San ',' Dingxi ','01-8 month -17');";

Write one more semicolon

java.sql.SQLException: ORA-01017: invalid username/password; login denied

User password error 、 User name error : 

java.sql.SQLException: Io abnormal :  The Network Adapter could not establish the connection at 

The firewall of the host to which you want to connect is turned off or its corresponding service is not turned on :

java.sql.SQLException: No sutiable driver found for jsbc:oracle1:thin:

 URL Wrong writing

 

 

原网站

版权声明
本文为[_ Qilixiang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206252020147907.html