listing 10-12.java

来自「这是JAVA开发大全的源代码」· Java 代码 · 共 31 行

JAVA
31
字号
String url = "jdbc:odbc:CustomerInformation";
String userID = "jim";
String password = "keogh";
String lastOrderNumber;
Connection Db;
try {
   Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
   Db = DriverManager.getConnection(url,userID,password);
 }
catch (ClassNotFoundException error) {
      System.err.println("Unable to load the JDBC/ODBC bridge." + 
             error);
      System.exit(1);
}
catch (SQLException error) {
      System.err.println("Cannot connect to the database." + error);
      System.exit(2);
}
try {
      String query = "{ CALL LastOrderNumber (?)}";
      CallableStatement cstatement = Db.prepareCall(query);
      cstatement.registerOutParameter(1, Types. VARCHAR);
      cstatement.execute();
                         lastOrderNumber = cstatement.getString(1);	cstatement.close();
 }
catch ( SQLException error ){
     System.err.println("SQL error." + error);
      System.exit(3);
}
Db.close();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?