import java.sql.*;
public class Jdbc {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("连接数据库成功");
} catch (ClassNotFoundException e) {
System.out.println("连接失败");
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Connection connect= DriverManager.getConnection(
"jdbc:mysql://localhost:3306/asda","root","root");
System.out.println("连接成功2222");
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery("select * from test02");
while(rs.next()) {
System.out.println(rs.getString("name"));
}
} catch (Exception e) {
System.out.println("get data erro!@!");
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}