java jdbc的连接数据库的使用
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();
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();
Last one:青丝(拼音版)
Next one:书记员2
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
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
登录后可见
用户更多文章推荐
- 二次元的都给我进来2021-05-30
- 来回拖动图片代码(HTML)2020-09-15
- 前端表格练习2020-09-14
- 数据库基本知识2020-08-06
- 卢本伟牛逼2024-03-05
- 六月的雨(纯手打 空格节奏,适合边听边...2020-07-02
- 编程必备训练2020-06-27
- C语言单词表及解释(开头为英文)2020-06-24
- 半岛铁盒2020-06-19
- 灌篮高手体会(强力推荐动漫)2020-06-19
- 女孩(中文版无标点)2020-06-16
- 爸爸的花儿落了(末尾片段)2020-06-14
- 七里香(中文版无标点)2020-06-14
- 程序员打字必备2020-06-10
- something(无任何大小写和标点)2020-06-07
- 明明就(中文版无标点)2020-06-07