How to connect jdbc to an oracle database

Source: Internet
Author: User

Import java. SQL .*;

Several issues to be aware of when Jbuilder correctly connects oracle Arrayi
The classes12.jar file should be used as the jdbc driver for oracle8 and later versions;
Correctly set the classpath for windows and enterprise setup and configure libraries in jbuilder, and add the casses12.jar path to the desired location;
Go to database pilot. In database pilot, file --- new in the driver list. If the oracle driver is red, your oralce fails to load in jb;
If ③ No error occurs, create a url: jdbc: oracle: thin: @ (yourhostname): 1521 :( your sid)
Username/password for database connection tutorial
Note: Most websites' jbuilder connection to oracle is caused by incorrect classpath configuration.
Connecting to an ORACLE database using a non-XA method
Note the following When configuring Oracle_XA in windows:

# ORACLE 10
Oracle_XA; xaosw; % ORACLE_HOME % dbms oraxa10.lib % ORACLE_HOME % precompibmsvcorasql10.lib

# Oracle Array
Oracle_XA; xaosw; % ORACLE_HOME % dbms oraxaArray. lib % ORACLE_HOME % precompibmsvcorasqlArray. lib

In Unix
Oracle_XA: xaosw :....

1. In windows, the semicolon ";" is followed by ORACLE_XA and xaosw, not the colon ":"
Second, the above LIB is written on one line, separated by spaces in the middle. If ORACLE_HOME is not set in the system environment variable, the absolute path is written.

'Java. SQL. SQLException: IO exception occurs during JDBC operations on the ORACLE database, not in stream mode'
Use OracleStatment instead of java. SQL. Statment
If setAutoCommit fails for an existing connection, close the connection and create a new connection.
Download the latest JDBC Driver from the ORACLE site. If you operate the LOB type, use the built-in ORACLE interfaces and classes.
Weblogic connection to oracle: The Network Adapter cocould not establish the connection

It may be because the server listening is stopped, which is a database issue and has nothing to do with the application. First, check whether oracle is normal and use SQL * plus to connect to the database;

 

2 // connect to the database with jdbc
3 public class zz {
4
5 /**
6 * @ param args
7 */
8 public static void main (String [] args ){
9 // TODO Auto-generated method stub
10
11 try
12 {
13 // load the driver
14 Class. forName ("oracle. jdbc. OracleDriver ");
15 Connection con = DriverManager. getConnection ("jdbc: oracle: thin: @ 127.0.0.1: 1521: ORACLE", "scott", "m123 ");
16 Statement sm = con. createStatement ();
17 ResultSet rs1_sm.exe cuteQuery ("select * from emp ");
18 System. out. println ("username:" + "position:" + "superior No.:" + "Start Time :");
19 while (rs. next ())
20 {
21
22 System. out. println (rs. getString (2) + "" + rs. getString (3) + "" + rs. getString (4) + "" + rs. getString (5 ));
23
24}
25 rs. close ();
26 sm. close ();
27 con. close ();
28}
29 catch (Exception e)
30 {
31 e. printStackTrace ();
32}
33
34}
35
36}

Considerations for using the Oracle connection pool and Oracle backup in eblogic
Use HP-UNIX, Weblogic 8.1, Oracle Array.2.0.5
A common connection pool is configured. The Driver uses oracle's Driver (Thin) version Array.0.1, Array.2.0

Error:
An error is reported when the database connection pool is used, indicating that there is no connection pool resource. In fact, the database connection pool is completely idle, and the test is correct. Oracle can also be connected and used normally.

Root cause:
Layer-by-layer troubleshooting, we found that Oracle exp was used in the background to back up a synonym-only user, resulting in the death of the exp process.
Killing exp and restarting Oracle cannot solve the problem. Eventually, UNIX is restarted. Only users with synonyms are prohibited from backing up.

Summary:
This should be caused by the exp BUG of mongolearray. Do not use exp to output synonyms.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.