* Connection Properties Recognized by Oracle jdbc Drivers
* -------------------------------------------------------
* Name Short Name Type Description
* ------------------- ---------- -------- -----------------------------------
* user n/a String The user name for logging into the
* database.
* password n/a String The password for logging into the
* database.
* database server String The connect string for the database.
* internal_logon n/a String A role, such as SYSDBA or SYSOPER,
* that allows you to log on as SYS.
* defaultRowPrefetch prefetch String (containing integer value)
* The default number of rows to
* prefetch from the server.
* (default value is "10")
* resReporting res String (containing boolean value)
* "true" if getTables() and
* getColumns() should report
* TABLE_REMARKS; equivalent to using
* setResReporting().
* (default value is "false")
* defaultBatchValue batchvalue String (containing integer value)
* The default batch value that triggers
* an execution request.
* (default value is "10")
* includeSynonyms synonyms String (containing boolean value)
* "true" to include column information
* from predefined "synonym" SQL
* entities when you execute a
* DataBaseMetaData getColumns() call;
* equivalent to connection
* setIncludeSynonyms() call.
* (default value is "false")
*
* -----------------------------------------------------------------------------
*/public class ConnectionOptions { final static String driverClass = "oracle.jdbc.driver.OracleDriver";
final static String connectionURL = "jdbc:oracle:thin:@HUQY:1521:TESTDB";
final static String userID = "scott";
final static String userPassword = "tiger";
Connection con = null;
/**
* Construct a QueryExample object. This constructor will create an Oracle
* database connection.
*/
public ConnectionOptions() { Properties conProps = new Properties();
conProps.put("user", userID);
conProps.put("password", userPassword);
conProps.put("defaultRowPrefetch", "15");
conProps.put("internal_logon", "sysdba"); try { System.out.print(" Loading jdbc Driver -> " + driverClass + "n");
Class.forName(driverClass).newInstance(); System.out.print(" Connecting to -> " + connectionURL + "n");
this.con = DriverManager.getConnection(connectionURL, conProps);
System.out.print(" Connected as -> " + userID + "n"); } catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
} catch (InstantiationException e) {
e.printStackTrace();
System.exit(1);
} catch (IllegalAccessException e) {
e.printStackTrace();
System.exit(1);
} catch (SQLException e) {
e.printStackTrace();
System.exit(1);
} }
...
}
* -------------------------------------------------------
* Name Short Name Type Description
* ------------------- ---------- -------- -----------------------------------
* user n/a String The user name for logging into the
* database.
* password n/a String The password for logging into the
* database.
* database server String The connect string for the database.
* internal_logon n/a String A role, such as SYSDBA or SYSOPER,
* that allows you to log on as SYS.
* defaultRowPrefetch prefetch String (containing integer value)
* The default number of rows to
* prefetch from the server.
* (default value is "10")
* resReporting res String (containing boolean value)
* "true" if getTables() and
* getColumns() should report
* TABLE_REMARKS; equivalent to using
* setResReporting().
* (default value is "false")
* defaultBatchValue batchvalue String (containing integer value)
* The default batch value that triggers
* an execution request.
* (default value is "10")
* includeSynonyms synonyms String (containing boolean value)
* "true" to include column information
* from predefined "synonym" SQL
* entities when you execute a
* DataBaseMetaData getColumns() call;
* equivalent to connection
* setIncludeSynonyms() call.
* (default value is "false")
*
* -----------------------------------------------------------------------------
*/public class ConnectionOptions { final static String driverClass = "oracle.jdbc.driver.OracleDriver";
final static String connectionURL = "jdbc:oracle:thin:@HUQY:1521:TESTDB";
final static String userID = "scott";
final static String userPassword = "tiger";
Connection con = null;
/**
* Construct a QueryExample object. This constructor will create an Oracle
* database connection.
*/
public ConnectionOptions() { Properties conProps = new Properties();
conProps.put("user", userID);
conProps.put("password", userPassword);
conProps.put("defaultRowPrefetch", "15");
conProps.put("internal_logon", "sysdba"); try { System.out.print(" Loading jdbc Driver -> " + driverClass + "n");
Class.forName(driverClass).newInstance(); System.out.print(" Connecting to -> " + connectionURL + "n");
this.con = DriverManager.getConnection(connectionURL, conProps);
System.out.print(" Connected as -> " + userID + "n"); } catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
} catch (InstantiationException e) {
e.printStackTrace();
System.exit(1);
} catch (IllegalAccessException e) {
e.printStackTrace();
System.exit(1);
} catch (SQLException e) {
e.printStackTrace();
System.exit(1);
} }
...
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货