1. Do not use Oracle. JDBC. Driver. The extended JDBC of Oracle is placed in the Oracle. JDBC package. The classes and interfaces described in this package are very similar to the methods described in Java. SQL. I think this should be a kind of Oracle sorting out JDBC, adjusting the original structure to make it more compliant with the specifications. From 9i, Oracle. JDBC. Driver package is not recommended. The code should use the Oracle. JDBC package. Although it continues to support the old package, this package should be deleted in the next major version to provide backward compatibility.
2. Precautions for using JDBC in a program:2.1. Import necessary JDBC classes such as import java. SQL .*;
Import Java. math. *; // if needed, to use oracledatasource, import: Import oracle. JDBC. pool. oracledatasource; 2. 2. create oracledatasource instance oracledatasource ODS = new oracledatasource (); 2. 3. set the required attributes when you do not want to use the default attributes. Different JDBC drivers should be used for different connection URLs. ODS. setuser ("my_user ");
ODS. setpassword ("my_password"); For jdbc oci driver: ODS. seturl ("JDBC: oracle: OCI: @"); remote connection: ODS. seturl ("JDBC: oracle: OCI: @ <database> ");
For JDBC thin driver, or server-side thin DRIVER:
ODS. seturl ("JDBC: oracle: thin: @ <database>"); where <database> is either a string of the form
// <Host>: <port>/<SERVICE_NAME>, or a SQL * Net name-value pair,
Or a tnsentryname. For the JDBC server-side internal DRIVER:
ODS. seturl ("JDBC: oracle: kprb:"); note that ':' At the end is required. When you use
Server-side internal driver, you always connect to
Database you are executing in. You can also do this: Connection conn =
New Oracle. JDBC. oracledriver (). defaultconnection (); 2.4. Use the getconnection () method to open the connection.
Connection conn = ODS. getconnection ();
3. If the data type is xmltype, data cannot be stored in clob mode. JDBC reports an unimplemented error.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.