java jdbc的连接数据库的使用

Contributor:在二次元打字 Type:代码 Date time:2020-08-06 16:35:08 Favorite:119 Score:0
返回上页 Report
请选择举报理由:




Collection Modify the typo
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "root";
String userpassword="123456";
Connection connection = DriverManager.getConnection(url, user, userpassword);
String sql="select teacher_id from t_teacher where teacher_name = zhangsan";
Statement state = connection.createStatement();
ResultSet rs= state.executeQuery(sql);
while(rs.next()) {
id= rs.getString("teacher_id");
}
String sql="select * from t_teacher where teacher_name = ? and password = ? ";
Connection connection = DriverManager.getConnection(url, username,userpassword);
PreparedStatement prepareState = connection.prepareStatement(sql);
prepareState.setString(1,name);
prepareState.setString(2,password);
ResultSet rs=prepareState.executeQuery();
int rs = prepareState.executeUpdate();
boolean rs = preapareState.execute();
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:
Difficulty:
quality:
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!

This paper typing ranking TOP20

登录后可见