手机怎么登录mysql 手机怎么登录路由器( 三 )


6 import java.sql.ResultSet;
7 import java.sql.SQLException;
8
9
10 public class TestCon1{
11public static void main(String[] args)
12{
13Connection con = null;
14String sql;
15PreparedStatement pre;
16ResultSet rs;
17
18try {
19String driver="com.mysql.jdbc.Driver";
20Class.forName(driver);
21
22String url="jdbc:mysql://localhost:3306/cuiuseUnicode=truecharacterEncoding=latin1";//utf-8也行
23con = DriverManager.getConnection(url, "root", "123456");
24
25sql = "select _id,username,password from test1" ;
26pre = con.prepareStatement(sql);
27
28rs = pre.executeQuery();
29while(rs.next()){
30int id = rs.getInt(1);
31String username = rs.getString(2);
32String password = rs.getString(3);
33
34System.out.println("id="+id+";username="+username+";password="+password);
35}
36con.close();
37} catch (SQLException e) {
38e.printStackTrace();
39} catch (ClassNotFoundException e) {
40e.printStackTrace();
41}
42
43}
44
45 }
运行结果:
id=1;username=ccc;password=123456
id=2;username=xxx;password=654321
id=3;username=ddd;password=123456
id=4;username=ddf÷;password=yyt
id=5;username=cuixiaodong;password=cxd
id=6;username=vv;password=cxd
【手机怎么登录mysql 手机怎么登录路由器】关于手机怎么登录mysql和手机怎么登录路由器的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读