import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class JDBC {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection
("jdbc:mysql://localhost:3306/demo"," ","1234");
System.out.println(conn);
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery("select * from user");
while(rs.next()){
System.out.println(rs.getString("name"));
System.out.println(rs.getString("password"));
}
} catch (Exception e) {
}
}
}
------解决方案--------------------
debug一下应该就清楚问题所在了