It's amazing, Code is a small problem for an afternoon.

xiaoxiao2021-03-06  41

Package OA; import java.sql. *;

public class DBConn {String sDBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String sConnStr = "jdbc: microsoft: sqlserver: //127.0.0.1: 1433; DatabaseName = office"; Connection conn = null; ResultSet rs = NULL; int = 0;

Public dbconn () {Try {class.Forname (SDBDriver); conn = drivermanager.getConnection (Sconnstr, "Center", "center");} catch (java.lang.classnotnotfoundexcect e) {system.err.println ("FAQ (): " E.GetMessage ());} catch (sqlexception ex) {system.err.println (" Aq.executeQuery: " ex.getMessage ());}}

Public int executeUpdate (String SQL) {Try {statement stmt = conn.createstatement (); rs2 = stmt.executeUpdate (SQL);

} Catch (sqlexception ex) {system.err.println ("Aq.executeQuery:" EX.GETMESSAGE ();} RETURN RS2;

} Public ResultSet ExecuteQuery (String SQL) {RS = NULL; Try {StMT.ExecuteQuery (SQL);

} Catch (sqlexception ex) {system.err.println ("Aq.executeQuery: ex. max);} Return RS;

}

}

Debugged in a afternoon, just started to adjust the executeQuery successfully debugged ExecuteUpdate, but the last baidujava.lang.nosuchmethError EXECUTEUPDATE results are possible to be Tomcat that did not detect the update of class files after you change, remove things in the works directory. Delete , Restart the server to try.

转载请注明原文地址:https://www.9cbs.com/read-53045.html

New Post(0)