![]() |
![]() |
Troubleshooting JDBC Hangs and SEGVsProblems with OracleSeveral conditions can cause segmentation violation errors (SEGVs) or hangs when you use JDBC and an Oracle database.
Out-of-Memory ErrorsA common cause of out-of-memory errors is failing to close ResultSets. The error message is usually similiar to the following:
To avoid out-of-memory errors, make sure that your program logic closes any ResultSets in all cases. To test whether failing to close ResultSets is causing the out-of-memory errors, minimize the size of the array fetches so that the amount of C memory allocated for selects is small. You can do this by setting the weblogic.oci.cacheRows property (a JDBC connection property) to a small number. For example, Properties props = new java.util.Properties(); props.put("user", "scott"); props.put("password", "tiger"); props.put("server", "DEMO" ); props.put("weblogic.oci.cacheRows", "1" ); Class.forName("weblogic.jdbc.oci.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:weblogic:oracle", props);If the out of memory errors cease, it is likely that ResultSets are not being closed somewhere in your code. For more information, see Closing JDBC Objects. Codeset SupportWebLogic supports Oracle codesets with the following considerations:
Other Problems with Oracle on UNIXCheck the threading model you are using. Green threads can conflict with the kernel threads used by OCI. When using Oracle drivers, WebLogic recommends that you use native threads. You can specify this by adding the -native flag when you start Java.If you are using the JVM for Solaris provided by Sun, you might want to switch to the JavaSoft JVM for Solaris, which WebLogic has found to be more stable. Thread-related Problems on UNIXOn UNIX, two threading models are available: green threads and native threads. For more information, see JDK for the Solaris Operating Environment on the JavaSoft Web site.You can determine what type of threads you are using by checking the environment variable called THREADS_TYPE. If this variable is not set, you can check the shell script in your Java installation bin directory. Some of the problems are related to the implementation of threads in the JVM for each operating system. Not all JVMs handle operating-system specific threading issues equally well. Here are some hints to avoid thread-related problems:
Closing JDBC ObjectsWebLogic also recommends -- and good programming practice dictates -- that you always close JDBC objects, like Connections, Statements, and ResultSets, in a finally block to make sure that your program executes efficiently. Here is a general example:try { Class.forName("weblogic.jdbc.oci.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:weblogic:oracle:myserver", "scott", "tiger"); Statement stmt = conn.createStatement(); stmt.execute("select * from emp"); ResultSet rs = stmt.getResultSet(); // do work } catch (Exception e) { // deal with any exceptions appropriate } finally { try {rs.close();} catch (Exception rse) {} try {stmt.close();} catch (Exception sse) {} try {conn.close(); catch (Exception cse) {} } |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|