Common Problems and Solutions for JDBC connection to Oracle databases

Source: Internet
Author: User
Tags dedicated server

Note:This article is excerpted from JDBC & Transaction to answer questions and answers from many friends. If you believe that the content of this article has violated your rights and interests, contact the Administrator to modify it.

  1. Several issues to be aware of when Jbuilder correctly connects to oracle 9i

    • 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

    Note:Most websites' jbuilder connection to oracle is caused by incorrect classpath configuration.

  2. 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 9
    Oracle_XA; xaosw; % ORACLE_HOME % dbms oraxa9.lib % ORACLE_HOME % precompibmsvcorasql9.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.

  3. 'Java. SQL. SQLException: IO exception occurs during JDBC operations on the ORACLE database, not in stream mode'
    1. Use OracleStatment instead of java. SQL. Statment
    2. If setAutoCommit fails for an existing connection, close the connection and create a new connection.
    3. Download the latest JDBC Driver from the ORACLE site. If you operate the LOB type, use the built-in ORACLE interfaces and classes.
  4. 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;

  5. Precautions for using the Oracle connection pool and Oracle backup in Weblogic

    Using HP-UNIX, Weblogic 8.1, Oracle 9.2.0.5
    A common connection pool is configured. The Driver uses oracle's Driver (Thin) version 9.0.1, 9.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:
    The exp BUG of Oracle9 causes connection pool problems. Do not use exp to output synonyms.

  6. The following exception is thrown during Oracle connection: java. SQL. SQLException: Io exception: The Network Adapter cocould not establish connection

    Oracle Database Connection (from oracle.com)
    PROBLEM
    You are attempting to connect to an Oracle instance using JDBC and you are inserting the following error.
    Java. SQL. SQLException: Io exception:
    The Network Adapter cocould not establish connection
    SQLException: SQLState (null) vendor code (17002)
    Any or all of the following conditions may also apply:
    1) You are able to establish a SQL * Plus connection from the same
    Client to the same Oracle instance.
    2) You are able to establish a jdbc oci connection, but not a Thin
    Connection from the same client to the same Oracle instance.
    3) The same JDBC application is able to connect from a different
    Client to the same Oracle instance.
    4) The same behavior applies whether the initial JDBC connection
    String specifies a hostname or an IP address.
    REDISCOVERY
    To verify whether you are hitting this problem, verify whether the Oracle instance is configured for Multithreaded Server (MTS ). if the Oracle instance is not configured for MTS, you are probably encountering a different problem. otherwise, continue. try forcing the JDBC connection to use a dedicated server instead of a shared server. this can be accomplished in several ways. for jdbc oci or Thin, this can be done by retrying ing the server for dedicated connections only. this approach, however, may not be feasible in your cases. in such cases, the following options apply: For jdbc oci:
    1) Add the (SERVER = DEDICATED) property to the TNS connect string
    Stored in the tnsnames. ora file on the client.
    2) Set the user_dedicated_server = ON in sqlnet. ora on the client.
    For JDBC Thin:
    You must specify a full name-value pair connect string (the same as it might appear in the tnsnames. ora file) instead of the short JDBC Thin syntax. For example, instead
    "Jdbc: oracle: thin: port: sid"
    You wowould need to use a string of the form
    "Jdbc: oracle: thin: @ (DESCRIPTION =" +
    "(ADDRESS_LIST =" +
    "(ADDRESS = (PROTOCOL = TCP)" +
    "(HOST = host)" + =
    "(PORT = port)" +
    ")" +
    ")" +
    "(CONNECT_DATA =" +
    "(SERVICE_NAME = sid)" +
    "(SERVER = DEDICATED)" +
    ")" +
    ")"
    If the connection works fine after having made these changes, it is very likely that this is the problem you are encountering. In this case, one last test will help to verify this fact.
    Log into the remote host on which the Oracle instance is running and execute the appropriate command to determine what the server 'thences' its hostname is (I. e. the name that was configured when the server was installed and configured ). for example, on a Unix host the 'hostname' command can be used for this purpose.
    Using the name displayed (e.g. by the hostname command), exactly as it appeared (I. e. if the output from the hostname command had the domain name has ded, then include it), return to the client which was unable to connect and try pinging the server.
    NOTE: It is critical that you attempt to ping the server using EXACTLY the same hostname you got from the server.
    If you are unable to ping the server via this hostname, then you almost certainly hitting this problem. if not, this may be a new issue, but at least you will have found a workaround (I. e. use a dedicated connection ).
    EXPLANATION
    To understand why this problem occurs, one must first understand the differences in how the listener handles connections to shared servers versus dedicated servers.
    When connecting to a dedicated server, the client connects to the listener (via hostname or IP address ). the listener then spawns a dedicated server process and hands off the socket used to accept the client connection to that server. the client and server then start communicating via the endpoints established by the initial connection. NOTE: There is only one connection in this case. when connecting to a shared server, the initial client connection to the listener is the same. however, with MTS, there is no need to spawn a new server process; a pool of shared processes already exists. also, clients do not communicate directly with the server processes in MTS; rather, they communicate with a dispatcher.
    For this reason, when setting up an MTS connection, the listener sends a redirect message back to the client asking the client to close the connection to the listener and connect to a dispatcher. the information in this message provided des the hostname and a port number for the appropriate dispatcher. the redirect message will ALWAYS specify a hostname, even if the client initially provided an IP address.
    If, for any reason, the hostname provided to the listener (e.g. by the 'hostname' or another command) doesn' t agree with the hostname by which the server is known on the client, the connection fails.
    On the other hand, if "(SERVER = DEDICATED)" already appears in the TNS connect string in tnsnames. ora or if "use_dedicated_server = ON" already appears in the sqlnet. ora file, you may find that SQL * Plus and/or JDBC OCI work fine, while JDBC Thin fails.
    SOLUTION
    Obviusly, one solution is to use dedicated servers. However, this may not always be feasible.
    The key is to make sure the hostname on both the client and server agree. this can be accomplished by reconfiguring either the client or the server, but there are things to be aware of in both cases.
    If the server is configured to return a different hostname, then it is possible that other clients which used to work will now fail.
    In some cases, it may not be feasible to reconfigure the client. for example, if the server version of the hostname does not include the domain, you wowould need to remove the domain portion of the hostname on the client;, if the client needs to connect to more than one server with the same base name in different domains, this may not be possible, as the hostname may be ambiguous.
    REFERENCES
    Bug: 1269734 java. SQL. SQLException: Io exception: The Network Adapter cocould not be found.

  7. Error in connecting to ORACLE Database: javax. naming. NameNotFoundException: Unable to resolve stored thin. Resolved: ''unresolved: 'stored thin'; remaining name''

    Problem description: After JDBC is configured, the following error message is displayed when the page is opened:
    Javax. naming. NameNotFoundException: Unable to resolve stored thin. Resolved: ''unresolved: 'stored thin'; remaining name''
    The JDBC configuration is as follows:
    Connection Pools (Connection pool)
    Name: descrithin
    URL: jdbc: oracle: thin.0.0.1: LYSIMIS
    Driver Classname: oracle. jdbc. driver. OracleDriver
    Properties:
    User = system
    Password = manager
    Dll = ocijdbc8
    Protocol = thin
    The data source configuration is as follows:
    Name: descrithin
    JNDI Name: OracThin
    Pool Name: effecthin
    An error occurs when the program executes this step.
    Ctx = new InitialContext ();
    Ds = (javax. SQL. DataSource) ctx. lookup ("thin ");

    After the problem is solved, Chinese characters are garbled.

    Cause and solution:

    • URL: jdbc: oracle: thin:. 0.0.1: 1521: LYSIMI, thin followed by:, 127.0.0.1 followed by port number
    • Note that the name is case sensitive.
    • Target to server
    • Check whether the pool is up. If it is not up, restart weblogic.
    • Garbled problem (Java is Unicode-based ):
      • Add <% @ page contentType = "text/html; charset = GBK" %> to the JSP file.
      • Add the following content to the <jsp-descriptor> section of the weblogic. xml file:
        <Jsp-descriptor>
        <Jsp-param>
        <Param-name> compilerSupportsEncoding </param-name>
        <Param-value> true </param-value>
        </Jsp-param>
        <Jsp-param>
        <Param-name> encoding </param-name>
        <Param-value> GBK </param-value>
        </Jsp-param>
        </Jsp-descriptor>
  8. Questions about oracle XA

    Problem description: Oracle_XA; xaosw; D: oracleora92 dbmsXAORAXA9.lib C: msvcoraSQL9.lib
    What does xaosw mean?

    A: You can refer to the XA documentation of ORACLE.

    Http://www-rohan.sdsu.edu/doc/oracle/server803/A54642_01/ch_xa.htm

  9. Oracle and weblogic Automatic Start and Stop

    Problem description: If the oracle database is not closed every time the server is restarted, it must be closed first and then restart the redhat advance server before oracle can run normally.

    For the causes and solutions, see:

    Http://dev2dev.bea.com.cn/bbs/thread.jspa? ForumID = 81 & threadID = 8839 & messageID = 43184 #43184

This article is only a small part of this version of the article. If you have not answered your questions, please refer to the essence of this version, you can also use the forum search function.

Sorting Date: 2005.9.26

Author Profile
Dev2dev ID: lhbing, dev2dev Forum moderator, WebLoigc, and Java technology enthusiast

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.