public static void main(String[] args) {
String usname= "root";
String pwd = "000000";
String driver="com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/zslm?user=root&password=000000"; //zslm是数据库名字,root是用户password//是密码
String sql = "select * from module";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(driver); //加载驱动
conn = DriverManager.getConnection(url); //获得连接
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs !=null){
while(rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getDate(3));
System.out.println(rs.getString(4));
System.out.println(rs.getString(5));
System.out.println(rs.getString(6));
System.out.println(rs.getString(7));
}
}else{
System.out.println("rs是null");
}
rs.close();
stmt.close();
rs.close();
} catch (ClassNotFoundException e){
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
mysql 3.2.7 驱动串 mysql驱动代码
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【驱动篇】龙芯LS2K0300之LED驱动
LED驱动及测试用例
龙芯 LS2K0300 LED 驱动 LoongArch