[求助]看看这个JDBC操作错误?
import java.sql.*;public class Demo{
protected final String driver="sun.jdbc.odbc.JdbcOdbcDriver";
protected final String source="jdbc:odbc:StudentInfo";
protected Connection connection;
protected Statement statement;
public void mm()throws SQLException{
try{
Class.forName(driver);
connection=DriverManager.getConnection(source);
statement=connection.createStatement();
String sql="CREATE TABLE 0511802006(Hid text,Hname text,Hstatus bit) ";
String s1="INSERT INTO 0511802006(Hid,Hname,Hstatus) VALUES ( '2','2002','1')";
statement.executeUpdate(s1);
ResultSet rs=statement.executeQuery(sql);
while(rs.next()){
String id=rs.getString("Hid");
String name=rs.getString("Hname");
String status=rs.getString("Hstatus");
System.out.println("Hid:"+"\t"+"Hname:"+"\t"+"Hstatus");
System.out.println(id+"\t"+name+"\t"+status);
}
statement.close();
}catch(SQLException e){
e.printStackTrace();
}catch(Exception exc){
exc.printStackTrace();
}
}
public static void main(String[] args)throws SQLException{
Demo d=new Demo();
d.mm();
}
}
这个程序执行后,在Acess2000中插入两个数据,这是为什么?