test 是你建立的数据库名称,比如你建立了一个学生信息数据库:
create database students;然后,在这个数据库中建立了两个表格:
use students; create table baseinfo(......);create table familys(...);
现在,你想通过程序查询学生的基本信息,你就可以这样做:
Connection con = DriverManage.getConnection(jdbc:mysql://localhost/students,"user","password");Statement stat= con.createStatement();
String strSQL = "select * from baseinfo";
ResultSet result;
try{
result = stet.executeQuery(strSQL);
}catch(SQLException e){
e.printStackTrace();
}//end try-catch
.......
create database students;然后,在这个数据库中建立了两个表格:
use students; create table baseinfo(......);create table familys(...);
现在,你想通过程序查询学生的基本信息,你就可以这样做:
Connection con = DriverManage.getConnection(jdbc:mysql://localhost/students,"user","password");Statement stat= con.createStatement();
String strSQL = "select * from baseinfo";
ResultSet result;
try{
result = stet.executeQuery(strSQL);
}catch(SQLException e){
e.printStackTrace();
}//end try-catch
.......
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货