什么都正常执行了,就是数据库里面的数据没有修改,搞不清楚是什么原因,郁闷呀!!!高手请给解决一下,只剩最后10分了!!
public static void main(String args[]){
DBConnectionManager db=new DBConnectionManager("sun.jdbc.odbc.JdbcOdbcDriver",
"jdbc:odbc:ServletDB",
null,
null);
}
public DBConnectionManager(String dbDriver, String dbURL, String userID, String passwd)
{
// use println statements to send status messages to web server console
try {
log("BookDataAccessor init: Start");
log("BookDataAccessor init: Loading Database Driver: " + dbDriver);
Class.forName(dbDriver);
log("BookDataAccessor init: Getting a connection to - " + dbURL);
Dbconnection = DriverManager.getConnection(dbURL, userID, passwd);
log("BookDataAccessor init: End");
updateList("1",10);
System.out.println("go");
}
catch (Exception e)
{
cleanUp();
log(e);
}
}
public void updateList(String _id,int _num)
{
strsql="Update book set num='" +_num + "' where ID='" + _id + "'";
try{
stmt= Dbconnection.createStatement();
System.out.println("have done");
stmt.executeUpdate(strsql);
System.out.println("result set closed");
}
catch (SQLException e)
{
System.out.println(e.getMessage()); }
}
public static void main(String args[]){
DBConnectionManager db=new DBConnectionManager("sun.jdbc.odbc.JdbcOdbcDriver",
"jdbc:odbc:ServletDB",
null,
null);
}
public DBConnectionManager(String dbDriver, String dbURL, String userID, String passwd)
{
// use println statements to send status messages to web server console
try {
log("BookDataAccessor init: Start");
log("BookDataAccessor init: Loading Database Driver: " + dbDriver);
Class.forName(dbDriver);
log("BookDataAccessor init: Getting a connection to - " + dbURL);
Dbconnection = DriverManager.getConnection(dbURL, userID, passwd);
log("BookDataAccessor init: End");
updateList("1",10);
System.out.println("go");
}
catch (Exception e)
{
cleanUp();
log(e);
}
}
public void updateList(String _id,int _num)
{
strsql="Update book set num='" +_num + "' where ID='" + _id + "'";
try{
stmt= Dbconnection.createStatement();
System.out.println("have done");
stmt.executeUpdate(strsql);
System.out.println("result set closed");
}
catch (SQLException e)
{
System.out.println(e.getMessage()); }
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货