-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestmysql.java
More file actions
31 lines (23 loc) · 823 Bytes
/
Copy pathtestmysql.java
File metadata and controls
31 lines (23 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package java_base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class testmysql {
public static void main(String[] args)throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
// Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:MySQL://127.0.0.1:3306/rhs?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC";
Connection conn = DriverManager.getConnection(url, "ming", "ming");
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery("select curtain_statu from app_user");
while(result.next())
{
System.out.println(result.getString(1));
}
stmt.close();
conn.close();
}
}