首先确定你是什么库啊,得有数据库驱动
例mysql
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection(url, name,
pwd);
con.setAutoCommit(false);
Connection conn = null;
ResultSet rs;
try {
conn = getConnect(url,name,password);
String sql="select * from table ";
PreparedStatement ps = conn.prepareStatement(sql);
rs = ps.executeQuery(sql);
while(rs.next()){
//rs.getString(1);根据类型取值
}
温馨提示:内容为网友见解,仅供参考