package com.access.database;
import java.sql.*;
public class JDBCAc {
public static void main(String[] args) {
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException e){
e.printStackTrace();
}
Connection con=null;
PreparedStatement stmt=null;
ResultSet rs=null;
try{
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/xjgl", "root", "zxs");
stmt=con.prepareStatement("select * from xjgl_xsb where xsxb=?");
stmt.setString(1, "男");
rs=stmt.executeQuery();
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5));
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
阅读(1235) | 评论(0) | 转发(0) |