以下是代码,黑色的部分也是代码的连续部分
package jdbcTest;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
public class test01 {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement ps = null;
try {
InputStream is = test01.class.getClassLoader().getResourceAsStream("jdbc.properties");
Properties pros = new Properties();
pros.load(is);
String user = pros.getProperty("user");
String password = pros.getProperty("password");
String url = pros.getProperty("url");
String driver = pros.getProperty("driver");
Class.forName(driver);
conn = DriverManager.getConnection(url,user,password);
// System.out.println(conn);
String sql = "insert into stuinfo(stuno,stuname) values (?,?)";
ps = conn.prepareStatement(sql);
ps.setString(1,"S777");
ps.setString(2, "罗辑");
ps.execute();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(ps != null){
ps.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
try {
if(conn != null){
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
图片是报错内容