Movatterモバイル変換


[0]ホーム

URL:


Skip navigation links

Overview Package  Class Tree Deprecated Index Help 
Oracle Database JDBC Java API Reference
11g Release 2

E13995-03
 PREV CLASS   NEXT CLASSFRAMES    NO FRAMES    
SUMMARY: NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD


oracle.jdbc
Class OracleDriver

java.lang.Object
  extended by oracle.jdbc.driver.OracleDriver
      extended by oracle.jdbc.OracleDriver

All Implemented Interfaces:
java.sql.Driver

public classOracleDriver
extends oracle.jdbc.driver.OracleDriver

The Oracle JDBC driver class that implements thejava.sql.Driver interface.

Register the JDBC drivers

To access a database from a Java application, you must first provide the code to register your installed driver with your program. You do this with the staticregisterDriver() method of thejava.sql.DriverManager class. This class provides a basic service for managing a set of JDBC drivers. TheregisterDriver() method takes as input a "driver" class, that is, a class that implements thejava.sql.Driver interface, as is the case withOracleDriver.

Note: Alternatively, you can use theforName() method of thejava.lang.Class class to load the JDBC drivers directly. For example:Class.forName ("oracle.jdbc.OracleDriver");. However, this method is valid only for JDK-compliant Java virtual machines. It is not valid for Microsoft Java virtual machines.

You register the driver only once in your Java application.

DriverManager.registerDriver (new oracle.jdbc.OracleDriver());

Open a Connection to a database

Once you have registered the driver, you can open a connection to the database with the staticgetConnection() method of thejava.sql.DriverManager class. The type of the object returned isjava.sql.Connection.

Understanding the Forms of getConnection()

Specifying a Databse URL, User Name, and Password

The following signature takes the URL, user name, and password as separate parameters:

getConnection(String URL, String user, String password);

Where the URL is of the form:
  jdbc:oracle:<drivertype>:@<database>

The following example connects userscott with passwordtiger to a database with SIDorcl through port 1521 of hostmyhost, using the Thin driver.

Connection conn = DriverManager.getConnection
  ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");

Specifying a Databse URL That Includes User Name and Password

The following signature takes the URL, user name, and password all as part of a URL parameter:

getConnection(String URL);

Where the URL is of the form:
  jdbc:oracle:<drivertype>:<user>/<password>@<database>

The following example connects userscott with passwordtiger to a database on hostmyhost using the OCI driver. In this case, however, the URL includes the userid and password, and is the only input parameter.

Connection conn = DriverManager.getConnection
   ("jdbc:oracle:oci8:scott/tiger@myhost);

If you want to connect with the Thin driver, you must specify the port number and SID. For example, if you want to connect to the database on hostmyhost that has a TCP/IP listener up on port 1521, and theSID (system identifier) isorcl:

Connection conn = DriverManager.getConnection
   ("jdbc:oracle:thin:scott/tiger@myhost:1521:orcl);

Specifying a Database URL and Properties Object

The following signature takes a URL, together with a properties object that specifies user name and password (perhaps among other things):

getConnection(String URL, Properties info);

Where theURL is of the form:
  jdbc:oracle:<drivertype>:@<database>

In addition to the URL, use an object of the standard JavaProperties class as input. For example:

java.util.Properties info = new java.util.Properties();
  info.put ("user", "scott");
  info.put (
"password","tiger");
  info.put ("defaultRowPrefetch","15");
  getConnection ("jdbc:oracle:oci8:@",info);

The table below lists the connection properties that Oracle JDBC drivers support.

Connection Properties Recognized by Oracle JDBC Drivers

NameShort NameTypeDescription
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 assysdba orsysoper, that allows you to log on assys 
defaultRowPrefetch prefetch String (containing integer value) the default number of rows to prefetch from the server (default value is "10") 
remarksReporting remarks String (containing boolean value) "true" if getTables() and getColumns() should report TABLE_REMARKS; equivalent to using setRemarksReporting() (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 aDataBaseMetaData getColumns() call; equivalent to connectionsetIncludeSynonyms() call (default value is "false") 
processEscapes n/a String (containing boolean value) "false" to disable escape processing for statements (Statement or PreparedStatement) created from this connection. Set this to "false" if you want to avoid many calls toStatement.setEscapeProcessing(false);. This is espcially usefull for PreparedStatement where a call tosetEscapeProcessing(false) would have no effect. The default is "true".  
defaultNChar n/a String (containing boolean value) "false" is the default. If set to "true", the default behavior for handling character datatypes is changed so that NCHAR/NVARCHAR2 become the default. This means that setFormOfUse() won't be needed anymore when using NCHAR/NVARCHAR2. This can also be set as a java property :
java -Doracle.jdbc.defaultNChar=true myApplication  
useFetchSizeWithLongColumn n/a String (containing boolean value) "false" is the default.
THIS IS A THIN ONLY PROPERTY. IT SHOULD NOT BE USED WITH ANY OTHER DRIVERS.
If set to "true", the performance when retrieving data in a 'SELECT' will be improved but the default behavior for handling LONG columns will be changed to fetch multiple rows (prefetch size). It means that enough memory will be allocated to read this data. So if you want to use this property, make sure that the LONG columns you are retrieving are not too big or you may run out of memory. This property can also be set as a java property :
java -Doracle.jdbc.useFetchSizeWithLongColumn=true myApplication  
SetFloatAndDoubleUseBinary n/a String (containing boolean value) "false" is the default.
If set to "true", causes the java.sql.PreparedStatment setFloat and setDouble API's to use internal binary format as for BINARY_FLOAT and BINARY_DOUBLE parameters.
See oracle.jdbc.OraclePreparedStatement setBinaryFloat and setBinaryDouble
 

Select your driver type : thin, oci, kprb...

Oralce provides four types of JDBC driver.


Field Summary
static booleanTRACE
           

 

Fields inherited from class oracle.jdbc.driver.OracleDriver
access_string, accumulate_batch_result, batch_string, convert_nchar_literals_string, database_string, dataSizeBytes, dataSizeChars, dataSizeUnitsPropertyName, default_execute_batch_string, default_row_prefetch_string, defaultnchar_string, defaultncharprop_string, disable_defineColumnType_string, dll_string, execute_batch_string, fixed_string_string, include_synonyms_string, j2ee_compliance, jdbc_string, logon_as_internal_str, nls_lang_backdoor, no_caching_buffers, oracle_string, password_string, permit_timestamp_date_mismatch_string, prefetch_string, prelim_auth_string, process_escapes_string, protocol_string, protocolFullName_string, proxy_client_name, read_timeout, remarks_string, report_remarks_string, restrict_getTables_string, retain_v9_bind_behavior_string, row_prefetch_string, server_string, set_new_password_string, SetFloatAndDoubleUseBinary_string, StreamChunkSize_string, synonyms_string, systemTypeMap, tcp_no_delay, useFetchSizeWithLongColumn_prop_string, useFetchSizeWithLongColumn_string, user_string, v8compatible_string, xa_trans_loose

 

Constructor Summary
OracleDriver()
           

 

Method Summary
static java.lang.StringgetBuildDate()
          Returns a String that specifies exactly when the jar file was built.
static java.lang.StringgetDriverVersion()
          Returns a String that specifies the Oracle version number of the driver.
static java.lang.StringgetJDBCVersion()
          Returns a String that specifies the version of the JDBC spec supporte by the driver.
static booleanisDebug()
          Returns true if this jar includes debug code.
static booleanisDMS()
          Returns true if this jar includes DMS instrumentaion.
static booleanisInServer()
          Returns true if this jar was built to run in the Oracle Java VM.
static booleanisJDK14()
          Deprecated.  
static booleanisPrivateDebug()
          Returns true if this jar includes Oracle internal debug code.
static voidmain(java.lang.String[] args)
          Prints a description of the Oracle JDBC driver .jar file to System.out.

 

Methods inherited from class oracle.jdbc.driver.OracleDriver
acceptsURL, connect, defaultConnection, getCompileTime, getMajorVersion, getMinorVersion, getPropertyInfo, getSystemPropertyFastConnectionFailover, jdbcCompliant, processSqlEscapes, registerMBeans

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

TRACE

public static final booleanTRACE
See Also:
Constant Field Values

Constructor Detail

OracleDriver

publicOracleDriver()

Method Detail

isDMS

public static final booleanisDMS()
Returns true if this jar includes DMS instrumentaion.
Returns:
true if DMS jar

isInServer

public static final booleanisInServer()
Returns true if this jar was built to run in the Oracle Java VM.
Returns:
true if server jar

isJDK14

public static final booleanisJDK14()
Deprecated. 
Returns true if this is a JDK 1.4 or later compliant jar. Since JDK 1.3 is desupported, always returns true.
Returns:
true

isDebug

public static final booleanisDebug()
Returns true if this jar includes debug code.
Returns:
true if debug jar

isPrivateDebug

public static final booleanisPrivateDebug()
Returns true if this jar includes Oracle internal debug code.
Returns:
true if private debug jar

getJDBCVersion

public static final java.lang.StringgetJDBCVersion()
Returns a String that specifies the version of the JDBC spec supporte by the driver.
Returns:
JDBC spec version

getDriverVersion

public static final java.lang.StringgetDriverVersion()
Returns a String that specifies the Oracle version number of the driver.
Returns:
version number

getBuildDate

public static final java.lang.StringgetBuildDate()
Returns a String that specifies exactly when the jar file was built.
Returns:
build date

main

public static voidmain(java.lang.String[] args)                 throws java.lang.Exception
Prints a description of the Oracle JDBC driver .jar file to System.out.
Parameters:
args - Ignored
Throws:
java.lang.Exception

Skip navigation links

Overview Package  Class Tree Deprecated Index Help 
Oracle Database JDBC Java API Reference
11g Release 2

E13995-03
 PREV CLASS   NEXT CLASSFRAMES    NO FRAMES    
SUMMARY: NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD


Copyright © 2009, Oracle and/or its affiliates. All rights reserved.

[8]ページ先頭

©2009-2026 Movatter.jp