81,111
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
public class Base{
/**
* @param args
*/ static void template() throws Exception {
String url="jdbc:mysql://localhost:3306/jsbc";
String user="root";
String password="admin";
Connection conn=null;
Statement st=null;
ResultSet rSet=null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection(url,user,password);
st=conn.createStatement();
rSet=st.executeQuery("select * from user");
while(rSet.next()){
System.out.println(rSet.getObject(1)+"\t"+rSet.getObject(2)
+"\t"+rSet.getObject(3)+"\t");
}
}
finally{
try{
if(rSet!=null)
rSet.close();
}finally{
try{
if(st!=null)
st.close();
}finally{
if(conn!=null)
conn.close();
}
}
}
}
public static void main(String[] args) throws Exception{
template();
}
}