Oracle-jdbc DML statements
Hi,
I tried executing multiple transaction about 1200 updation by reading an excelsheet and updating same on tables.
But one error which i faced was "Connection exceed maximum no of cursors" after some no of DML statements.
If i use batch updation or connection.commit() after making
setAutoComiit(false) ,will this bug be ok ?.So long i was directly using
execute().I read about these methods today and found i was not using them.
Plz let me know.
You can't search? I find that amazing. You respond rather quickly to my suggestions, why not apply the same industry to Google?
How about closing your resources?
Similar Messages
-
How to get comparable Oracle JDBC performance using Java 1.4 vs 1.1.7?
Our application makes extensive use of JDBC to access an Oracle database. We wrote it a number of years ago using java 1.1.7 and we have been unable to move to new versions of java because of the performance degradation.
I traced the problem to JDBC calls. I can reproduce the problem using a simple program that simply connects to the database, executes a simple query and then reads the data. The same program running under java 1.4 is about 60% slower than under java 1.1.7. The query is about 80% slower and getting the data is about 150% slower!
The program is attached below. Note, I run the steps twice as the first time the times are much larger which I attribute to java doing some initializations. So the second set of values I think are more representative of the actual performance in our application where there are numerous accesses to the database. Specifically, I focus on step 4 which is the execute query command and step 5 which is the data retrieval step. The table being read has 4 columns with 170 tuples in it.
Here are the timings I get when I run this on a Sparc Ultra 5 running
SunOs 5.8 using an Oracle database running 8.1.7:
java 1.1.7 java 1.4
overall: 2.1s 3.5s
step 1: 30 200
step 2: 886 2009
step 3: 2 2
step 4: 9 17
step 5: 122 187
step 6: 1 1
step 1: 0 0
step 2: 203 161
step 3: 0 1
step 4: 8 15 <- 87% slower
step 5: 48 117 <- 143% slower
step 6: 1 2I find the same poor performance from java versions 1.2 and 1.3.
I tried using DataDirect's type 4 JDBC driver which gives a little better performance but overall it is still much slower than using java 1.1.7.
Why do the newer versions of java have such poor performance when using JDBC?
What can be done so that we can have performance similar to java 1.1.7
using java 1.4?
========================================================================
import java.util.*;
import java.io.*;
import java.sql.*;
public class test12 {
public static void main(String args[]) {
try {
long time1 = System.currentTimeMillis();
/* step 1 */ DriverManager.registerDriver(
new oracle.jdbc.driver.OracleDriver());
long time2 = System.currentTimeMillis();
/* step 2 */ Connection conn = DriverManager.getConnection (
"jdbc:oracle:thin:@dbserver1:1521:db1","user1","passwd1");
long time3 = System.currentTimeMillis();
/* step 3 */ Statement stmt = conn.createStatement();
long time4 = System.currentTimeMillis();
/* step 4 */ ResultSet rs = stmt.executeQuery("select * from table1");
long time5 = System.currentTimeMillis();
/* step 5 */ while( rs.next() ) {
int message_num = rs.getInt(1);
String message = rs.getString(2);
long time6 = System.currentTimeMillis();
/* step 6 */ rs.close(); stmt.close();
long time7 = System.currentTimeMillis();
System.out.println("step 1: " + (time2 - time1) );
System.out.println("step 2: " + (time3 - time2) );
System.out.println("step 3: " + (time4 - time3) );
System.out.println("step 4: " + (time5 - time4) );
System.out.println("step 5: " + (time6 - time5) );
System.out.println("step 6: " + (time7 - time6) );
System.out.flush();
} catch ( Exception e ) {
System.out.println( "got exception: " + e.getMessage() );
... repeat the same 6 steps again...
}If I run my sample program with the -server option, it
takes a lot longer (6.8s vs 3.5s).Which has to be expected, as the -server option optimizes for long running programs - so it shoudl go with my second suggestion, more below...
I am not certain what you mean by "just let the jvm
running". Our users issue a command (in Unix) which
invokes one of our java programs to access or update
data in a database. I think what you are suggesting
would require that I rewrite our application to have a
java program always running on the users workstation
and to also rewrite our
commands (over a hundred) to some how pass data and
receive data with this new server java program. That
does not seem a very reasonable just to move to a new
version of java. Or are you suggesting something
else?No I was just suggestion what you descript. But if this is not an option, then maybe you should merge your java-programs to C or another native language. Or you could try the IBM-JDK with the -faststart (or similar) option. If thew Unix you mention is AIX, then there would be the option of a resetable-vm. But I cannot say if this VM would solve your problem. Java is definitly not good for applications which only issue some unqiue commands because the hotspot-compiler can not be efficiently used there. You can only try to get 1.1.7 performance by experimenting with vm-parameters (execute java -X). -
A sign Applet unable to load "oracle.jdbc.OracleDriver" class
hi,
i am chiranjit , i am now working in a web based ERP. where i am using a signed applet which unable to load "oracle.jdbc.OracleDriver" class but it easily loading "sun.jdbc.odbc.JdbcOdbcDriver", i am also giving my code:
import java.sql.*;
import java.math.*;
import java.io.*;
import java.awt.*;
class JdbcTest extends Applet{
public static void main (String args[]) throws SQLException {
// Load Oracle driver
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
// Connect to the local database
Connection conn =
DriverManager.getConnection
("jdbc:oracle:thin:@192.168.16.7:1521:kris",
"plsql", "oracle");
// Query the employee names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT FIRST_NAME FROM
AUTHORS");
// Print the name out
while (rset.next ())
System.out.println (rset.getString (1));
// Close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
}Hint: The sun.jdbc.odbc.JdbcOdbcDriver is available in any JRE distribution. The Oracle driver is not.
-
Hi
I am trying to use type 4 driver to connect to my Oracle 9i Rel2 database. I downloaded the odbc14.jar from oracle and added in the C:\Oracle9i\jdbc\lib path. As on the website, I setup my environment:
Setting Up Your Environment
On Win95/Win98/NT:
- Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
(Add classes12.zip and nls_charset12.zip if JDK 1.2.x or 1.3 is
used. Add ojdbc14.jar and nls_charset12.zip if JDK 1.4 is used.)
- Make sure [ORACLE_HOME]\bin is in your PATH.
Still I am getting the following error during runtime:
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:11)
Below is the source code:
import java.sql.*;
import java.io.*;
public class InsertQueryEx {
public static void main(String[] args)throws Exception{
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@Prashy:1521:orcl", "scott", "tiger");
DataInputStream din = new DataInputStream(System.in);
Statement stmt = con.createStatement();
while(true){
try{
System.out.println("enter emp name");
String name = din.readLine();
System.out.println("enter emp no");
int no = Integer.parseInt(din.readLine());
System.out.println("enter emp salary");
float sal = Float.parseFloat(din.readLine());
System.out.println("enter emp address");
String addr = din.readLine();
int count = stmt.executeUpdate("insert into myemp values("+no+",'"+name+"',"+sal+",'"+addr+"')");
if(count>0)
System.out.println("Record added");
else
System.out.println("Failed");
catch (Exception e){
System.err.println("Exception: "+e.getMessage());
Any help is appreciated
Thanks
PrashantI am sorry but I did add those in the classpath but still getting this error:
This is what I have for user variable in classpath:
.;C:\Oracle9i\jdbc\lib\ojdbc14.jar;C:\Oracle9i\jdbc\lib\nls_charset12.jar
error is:
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:14)
Thanks -
Error while registering Oracle JDBC Diagnosability MBean
Hi All,
I get the following error (pasted at the end)when trying to use the OracleDriver class to create connections.
I am using JDeveloper11g-11.1.1.2.0, and
JDeveloper11g-11.1.1.2.0/wlserver_10.3/server/ext/jdbc/oracle/11g/ojdbc6.jar.
I read other posts with similar errors; the recommendation was to update the jar to the latest patch. But that still does not seem to work.
Any help/pointers appreciated.
Thanks
Meera
------------ Error trace ----------------------------------------------------
SEVERE: Error while registering Oracle JDBC Diagnosability MBean.
java.security.AccessControlException: access denied (javax.management.MBeanTrustPermission register)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:568)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1824)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:310)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:345)
at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:193)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at oracle.communications.brm.pdc.server.transfomation.CrossReferenceDBConnectionObj.initializeConnection(Unknown Source)
at oracle.communications.brm.pdc.server.transfomation.CrossReferenceHandler.<init>(Unknown Source)
at oracle.communications.brm.pdc.server.transfomation.RRE_TransformationEngine.createWorkItemProcessors(Unknown Source)
at oracle.communications.brm.pdc.server.junit.RRE_TransformationEngineTests.testCreateWorkItemProcessors(Unknown Source)
at oracle.communications.brm.pdc.server.junit.RRE_TransformationEngineTests.testMain(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runners.Suite.runChild(Suite.java:115)
at org.junit.runners.Suite.runChild(Suite.java:23)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)Hi,
did you enable the permission at the jvm level?
its' done by adding the following lines to your java.policy file under <JRE_HOME>/lib/security
grant {
// JMX Java Management eXtensions
permission javax.management.MBeanTrustPermission "register";
ciao,
Giovanni
P.S. This solution was taken from http://forums.sun.com/thread.jspa?threadID=491124 -
Oracle JDBC Driver 10.1.0.4.0 and IndexOutOfBounds-Exception
Hello all,
we´ve experienced a weird problem using the Oracle JDBC driver version 10.1.0.4.0. While executing SELECT statement we get an ArrayIndexOutOfBounds exception from the JDBC driver. Here´s the stacktrace:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at oracle.jdbc.driver.T4CDateAccessor.saveDataFromOldDefineBuffers(T4CDateAccessor.java:212)
at oracle.jdbc.driver.T4CPreparedStatement.saveDefineBuffersIfRequired(T4CPreparedStatement.java:405)
at oracle.jdbc.driver.OracleStatement.prepareAccessors(OracleStatement.java:859)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:949)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:532)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1037)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2905)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2946)
at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:124)
We couldn´t find anything on the web on this error. We´re using Weblogic 8.1 SP4 with JDBC version. Does anyone have a hint or an idea what could be the problem here?
Thanks for any help in advance!
Cheers,
JoergI may have a related bug, I get a similiar exception when running JIRA...
java.lang.ArrayIndexOutOfBoundsException: -1
at oracle.jdbc.driver.DateTimeCommonAccessor.computeJulianDay(DateTimeCommonAccessor.java:341)
at oracle.jdbc.driver.DateTimeCommonAccessor.getMillis(DateTimeCommonAccessor.java:386)
at oracle.jdbc.driver.DateAccessor.getTimestamp(DateAccessor.java:142)
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetImpl.java:1018)...I tried the 10.1.0.2 and 10.1.0.4 drivers, both throw the same exception. I would try the 10.2 drivers, but they just hang! Gotta love Oracle QA! -
Bug in Oracle JDBC Pooling Classes - Deadlock
We are utilizing Oracle's connection caching (drivers 10.2.0.1) and have found a deadlock situation. I reviewed the code for the (drivers 10.2.0.3) and I see the same problem could happen.
I searched and have not found this problem identified anywhere. Is this something I should post to Oracle in some way (i.e. Metalink?) or is there a better forum to get this resolved?
We are utilizing an OCI driver with the following setup in the server.xml
<ResourceParams name="cmf_toolbox">
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>user</name>
<value>hidden</value>
</parameter>
<parameter>
<name>password</name>
<value>hidden</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:oci:@PTB2</value>
</parameter>
<parameter>
<name>connectionCachingEnabled</name>
<value>true</value>
</parameter>
<parameter>
<name>connectionCacheProperties</name>
<value>(InitialLimit=5,MinLimit=15,MaxLimit=75,ConnectionWaitTimeout=30,InactivityTimeout=300,AbandonedConnectionTimeout=300,ValidateConnection=false)</value>
</parameter>
</ResourceParams>
We get a deadlock situation between two threads and the exact steps are this:
1) thread1 - The OracleImplicitConnectionClassThread class is executing the runAbandonedTimeout method which will lock the OracleImplicitConnectionCache class with a synchronized block. It will then go thru additional steps and finally try to call the LogicalConnection.close method which is already locked by thread2
2) thread2 - This thread is doing a standard .close() on the Logical Connection and when it does this it obtains a lock on the LogicalConnection class. This thread then goes through additional steps till it gets to a point in the OracleImplicitConnectionCache class where it executes the reusePooledConnection method. This method is synchronized.
Actual steps that cause deadlock:
1) thread1 locks OracleImplicitConnectionClass in runAbandonedTimeout method
2) thread2 locks LogicalConnection class in close function.
3) thread1 tries to lock the LogicalConnection and is unable to do this, waits for lock
4) thread2 tries to lock the OracleImplicitConnectionClass and waits for lock.
***DEADLOCK***
Thread Dumps from two threads listed above
thread1
Thread Name : Thread-1 State : Deadlock/Waiting on monitor Owns Monitor Lock on 0x30267fe8 Waiting for Monitor Lock on 0x509190d8 Java Stack at oracle.jdbc.driver.LogicalConnection.close(LogicalConnection.java:214) - waiting to lock 0x509190d8> (a oracle.jdbc.driver.LogicalConnection) at oracle.jdbc.pool.OracleImplicitConnectionCache.closeCheckedOutConnection(OracleImplicitConnectionCache.java:1330) at oracle.jdbc.pool.OracleImplicitConnectionCacheThread.runAbandonedTimeout(OracleImplicitConnectionCacheThread.java:261) - locked 0x30267fe8> (a oracle.jdbc.pool.OracleImplicitConnectionCache) at oracle.jdbc.pool.OracleImplicitConnectionCacheThread.run(OracleImplicitConnectionCacheThread.java:81)
thread2
Thread Name : http-7320-Processor83 State : Deadlock/Waiting on monitor Owns Monitor Lock on 0x509190d8 Waiting for Monitor Lock on 0x30267fe8 Java Stack at oracle.jdbc.pool.OracleImplicitConnectionCache.reusePooledConnection(OracleImplicitConnectionCache.java:1608) - waiting to lock 0x30267fe8> (a oracle.jdbc.pool.OracleImplicitConnectionCache) at oracle.jdbc.pool.OracleConnectionCacheEventListener.connectionClosed(OracleConnectionCacheEventListener.java:71) - locked 0x34d514f8> (a oracle.jdbc.pool.OracleConnectionCacheEventListener) at oracle.jdbc.pool.OraclePooledConnection.callImplicitCacheListener(OraclePooledConnection.java:544) at oracle.jdbc.pool.OraclePooledConnection.logicalCloseForImplicitConnectionCache(OraclePooledConnection.java:459) at oracle.jdbc.pool.OraclePooledConnection.logicalClose(OraclePooledConnection.java:475) at oracle.jdbc.driver.LogicalConnection.closeInternal(LogicalConnection.java:243) at oracle.jdbc.driver.LogicalConnection.close(LogicalConnection.java:214) - locked 0x509190d8> (a oracle.jdbc.driver.LogicalConnection) at com.schoolspecialty.cmf.yantra.OrderDB.updateOrder(OrderDB.java:2022) at com.schoolspecialty.cmf.yantra.OrderFactoryImpl.saveOrder(OrderFactoryImpl.java:119) at com.schoolspecialty.cmf.yantra.OrderFactoryImpl.saveOrder(OrderFactoryImpl.java:67) at com.schoolspecialty.ecommerce.beans.ECommerceUtil.saveOrder(Unknown Source) at com.schoolspecialty.ecommerce.beans.ECommerceUtil.saveOrder(Unknown Source) at com.schoolspecialty.ecommerce.beans.UpdateCartAction.perform(Unknown Source) at com.schoolspecialty.mvc2.ActionServlet.doPost(ActionServlet.java:112) at com.schoolspecialty.ecommerce.servlets.ECServlet.doPostOrGet(Unknown Source) at com.schoolspecialty.ecommerce.servlets.ECServlet.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.schoolspecialty.ecommerce.servlets.filters.EcommerceURLFilter.doFilter(Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534)We used a documented option to abandon connects in the case of an unforeseen error. The consequence of using this option was not a graceful degradation in performance but a complete lockup of the application. The scenario in which we created a moderate number of abandoned connections was a rare error scenario but a valid test.
How could this not be a bug in the Oracle driver? Is dead-lock a desireable outcome of using an option? Is dead-lock ever an acceptable consequence of using a feature as documented?
Turns out other Oracle options to recover from an unexpected error also incur a similar deadlock (TimeToLiveTimeout).
I did a code review of the decompiled drivers and it clearly shows the issue, confirming the original report of this issue. Perhaps you have evidence to the contrary or better evidence to support your statement "not a bug in Oracle"?
Perhaps you are one of the very few people who have not experience problems with Oracle drivers? I've been using Oracle since 7.3.4 and it seems that I have always been working around Oracle JDBC driver problems.
We are using Tomcat with the OracleDataSourceFactory. -
Bug in Oracle JDBC thin driver (parameter order)
[ I'd preferably send this to some Oracle support email but I
can't find any on both www.oracle.com and www.technet.com. ]
The following program illustrates bug I found in JDBC Oracle thin
driver.
* Synopsis:
The parameters of prepared statement (I tested SELECT's and
UPDATE's) are bound in the reverse order.
If one do:
PreparedStatement p = connection.prepareStatement(
"SELECT field FROM table WHERE first = ? and second = ?");
and then bind parameter 1 to "a" and parameter to "b":
p.setString(1, "a");
p.setString(2, "b");
then executing p yields the same results as executing
SELECT field FROM table WHERE first = "b" and second = "a"
although it should be equivalent to
SELECT field FROM table WHERE first = "a" and second = "b"
The bug is present only in "thin" Oracle JDBC driver. Changing
driver to "oci8" solves the problem.
* Version and platform info:
I detected the bug using Oracle 8.0.5 server for Linux.
According to $ORACLE_HOME/jdbc/README.doc that is
Oracle JDBC Drivers release 8.0.5.0.0 (Production Release)
* The program below:
The program below illustrates the bug by creating dummy two
column table, inserting the row into it and then selecting
the contents using prepared statement. Those operations
are performed on both good (oci8) and bad (thin) connections,
the results can be compared.
You may need to change SID, listener port and account data
in getConnecton calls.
Sample program output:
$ javac ShowBug.java; java ShowBug
Output for both connections should be the same
--------------- thin Driver ---------------
[ Non parametrized query: ]
aaa
[ The same - parametrized (should give one row): ]
[ The same - with buggy reversed order (should give no answers):
aaa
--------------- oci8 driver ---------------
[ Non parametrized query: ]
aaa
[ The same - parametrized (should give one row): ]
aaa
[ The same - with buggy reversed order (should give no answers):
--------------- The end ---------------
* The program itself
import java.sql.*;
class ShowBug
public static void main (String args [])
throws SQLException
// Load the Oracle JDBC driver
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
System.out.println("Output for both connections should be the
same");
Connection buggyConnection
= DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:ORACLE",
"scott", "tiger");
process("thin Driver", buggyConnection);
Connection goodConnection
= DriverManager.getConnection ("jdbc:oracle:oci8:",
"scott", "tiger");
process("oci8 driver", goodConnection);
System.out.println("--------------- The end ---------------");
public static void process(String title, Connection conn)
throws SQLException
System.out.println("--------------- " + title + "
Statement stmt = conn.createStatement ();
stmt.execute(
"CREATE TABLE bug (id VARCHAR(10), val VARCHAR(10))");
stmt.executeUpdate(
"INSERT INTO bug VALUES('aaa', 'bbb')");
System.out.println("[ Non parametrized query: ]");
ResultSet rset = stmt.executeQuery(
"select id from bug where id = 'aaa' and val = 'bbb'");
while (rset.next ())
System.out.println (rset.getString (1));
System.out.println("[ The same - parametrized (should give one
row): ]");
PreparedStatement prep = conn.prepareStatement(
"select id from bug where id = ? and val = ?");
prep.setString(1, "aaa");
prep.setString(2, "bbb");
rset = prep.executeQuery();
while (rset.next ())
System.out.println (rset.getString (1));
System.out.println("[ The same - with buggy reversed order
(should give no answers): ]");
prep = conn.prepareStatement(
"select id from bug where id = ? and val = ?");
prep.setString(1, "bbb");
prep.setString(2, "aaa");
rset = prep.executeQuery();
while (rset.next ())
System.out.println (rset.getString (1));
stmt.execute("DROP TABLE bug");
nullHorea
In the ejb-jar.xml, in the method a cursor is closed, set <trans-attribute>
to "Never".
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name></ejb-name>
<method-name></method-name>
</method>
<trans-attribute>Never</trans-attribute>
</container-transaction>
</assembly-descriptor>
Deepak
Horea Raducan wrote:
Is there a known bug in Oracle JDBC thin driver version 8.1.6 that would
prevent it from closing the open cursors ?
Thank you,
Horea -
Bug in Oracle JDBC Driver: NullPointerException when calling clearParameters
There is a bug in the latest version of the JDBC driver that throws a NPE when calling PreparedStatement.clearParameters(). I don't need a response to this, since I have a workaround (just catching and ignoring the exception), but it should probably be fixed. I speculate that the problem only occurs when you try to call clearParameters() more than once on the same PS, but I haven't confirmed it.
It is probably an easy fix. Following is the stack trace:
java.lang.NullPointerException
at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
at com.solarmetric.datasource.PreparedStatementCache$CachePreparedStatement.close(PreparedStatementCache.java:293)
at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementBatch(SQLExecutionManagerImpl.java:666)
at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:514)
at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:406)
at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:273)
at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:421)
at com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:549)
at com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:412)
at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.testMakePersistentAssignsObjectId2(Unknown Source)
at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.testMakePersistentAssignsObjectId(Unknown Source)
at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.runTest(Unknown Source)
at com.sun.jdotck.api.persistencemanager.PersistenceManagerTest.run(Unknown Source)
at com.solarmetric.kodo.compatibility.JDOCompatabilityTestSuite$1.runTest(JDOCompatabilityTestSuite.java:493)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:524)
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.comTake a look at the method that is causing the NullPointerException:
public void clearItem(int i)
if (!m_dynamic && m_vector == null && i < m_vector.size())
m_vector.removeElementAt(i);
if (m_items != null && i >= m_items.length)
return;
m_items[i] = null;
return;
A NullPointerException will be thrown whenever clearParameters() is called when no parameters have yet been bound.
The first IF statement should read:
if (!m_dynamic && m_vector != null && i < m_vector.size())
A simple workaround would be to make sure that your parameter list is never empty before calling clearParameters(). Is there a patch for this anywhere? -
Differences between Oracle JDBC Thin and Thick Drivers
If any body is looking for this information...
============================================================
I have a question concerning the Oracle JDBC thin vs. thick drivers
and how they might affect operations from an application perspective.
We're in a Solais 8/Oracle 8.1.7.2 environment. We have several
applications on several servers connecting to the Oracle database.
For redundancy, we're looking into setting up TAF (transparent
application failover). Currently, some of our apps use the Oracle
<B>JDBC thin</B> drivers to talk to the database, with a connection
string that like this:
<B> jdbc:oracle:thin:@host:port:ORACLE_SID </B>
In a disaster recovery mode, where we would switch the database
from one server to another, the host name in the above string
would become invalid. That means we have to shut down our application
servers and restart them with an updated string.
Using the Oracle <B>OCI (thick)</B> driver though, allows us to connect
to a Net8 service instead of a specific server:
<B> jdbc:oracle:oci8:@NET8_SERVICE_NAME </B>
Coupled with the FAILOVER=ON option configured in Net8, it is
then possible to direct a connection from the first server to
the failover database on another server. This is exactly what
we would like to do.
My question is, from an application perspective, how is the Oracle
thick driver different from the thin driver? If everything
else is "equal" (i.e. the thick driver is compatible with the
app servers) would there be something within the the thick/OCI
driver that could limit functionality vs. the thin driver?
My understand, which obviously is sketchy, is that the thick
driver is a superset of the thin driver. If this is the case,
and for example if all database connections were handled through
a configuration file with the above OCI connection string, then
theoretically the thick driver should work.
============================================================
<B>
In the case with the Oracle, they provide a thin driver that is a 100% Java driver for client-side use without the need of an Oracle installation (maybe that's why we need to input server name and port number of the database server). This is platform indipendent, and has good performance and some features.
The OCI driver on the other hand is not java, require Oracle installation, platform dependent, performance is faster, and has a complete list of all the features.
</B>
========================================================
I hope this is what you expect.
JDBC OCI client-side driver: This is a JDBC Type 2 driver that uses Java native methods to call entrypoints in an underlying C library. That C library, called OCI (Oracle Call Interface), interacts with an Oracle database. <B>The JDBC OCI driver requires an Oracle (7.3.4 or above) client installation (including SQL*Net v2.3 or above) and all other dependent files.</B> The use of native methods makes the JDBC OCI driver platform specific. Oracle supports Solaris, Windows, and many other platforms. This means that the Oracle JDBC OCI driver is not appropriate for Java applets, because it depends on a C library to be preinstalled.
JDBC Thin client-side driver: This is a JDBC Type 4 driver that uses Java to connect directly to Oracle. It emulates Oracle's SQL*Net Net8 and TTC adapters using its own TCP/IP based Java socket implementation. <B>The JDBC Thin driver does not require Oracle client software to be installed, but does require the server to be configured with a TCP/IP listener. Because it is written entirely in Java, this driver is platform-independent.</B> The JDBC Thin driver can be downloaded into any browser as part of a Java application. (Note that if running in a client browser, that browser must allow the applet to open a Java socket connection back to the server.
JDBC Thin server-side driver: This is another JDBC Type 4 driver that uses Java to connect directly to Oracle. This driver is used internally by the JServer within the Oracle server. This driver offers the same functionality as the client-side JDBC Thin driver (above), but runs inside an Oracle database and is used to access remote databases. Because it is written entirely in Java, this driver is platform-independent. There is no difference in your code between using the Thin driver from a client application or from inside a server.
======================================================
How does one connect with the JDBC Thin Driver?
The the JDBC thin driver provides the only way to access Oracle from the Web (applets). It is smaller and faster than the OCI drivers, and doesn't require a pre-installed version of the JDBC drivers.
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@qit-uq-cbiw:1526:orcl", "scott", "tiger");
// @machineName:port:SID, userid, password
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
How does one connect with the JDBC OCI Driver?
One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci8:@qit-uq-cbiw_orcl", "scott", "tiger");
// or oci7 @TNSNames_Entry, userid, password
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
=================================================================Wow, not sure what your question was, but there sure was a lot of information there...
There really is only one case where failover occurs, and it would not normally be in a disaster recovery situation, where you define disaster recovery as the obliteration of your current server farm, network and concievably the operational support staff. This would require a rebuild of your server, network etc and isn't something done with software.
Fail over is normally used for high availablity that would take over in case of hardware server failure, or when your support staff wants to do maintenance on the primary server.
Using the thin and thick driver should have ZERO affect on a failover. Transparent failover will make the secondary server the same IP as the primary, therefore the hostname will still point to the appropriate server. If you are doing this wrong, then you will have to point all your applications to a new IP address. This should be something that you tell your management is UNACCEPTABLE in a fail-over situation, since it is almost sure to fail to fail-over.
You point out that you are providing the TNSNAME, rather than the HOSTNAME when using the thick driver. That's true within your application, but that name is resolved to either a HOSTNAME, or IP ADDRESS before it is sent to the appropriate Oracle server/instance. It is resolved using either a NAME server (same as DNS server but for Oracle), or by looking at a TNSNAMES file. Since the TNSNAMES files profilerate like rabbits within an organization you don't want a fail over that will make you find and switch all the entries, so you must come up with a fail over that does not require it.
So, the application should not be concerned with either the hostname, or the IP address changing during fail over. That makes use of the thin or thick client acceptable for fail over.
Don't know if this will help, but this shows the communication points.
THIN DRIVER
client --> dns --> server/port --> SID
THICK DRIVER
client --> names server --> dns --> server/port --> SID
client --> tnsnames --> dns --> server/port --> SID -
Hi,
I am trying to setup a file to Oracle JDBC receiver scenario. In this case I am trying to just insert a single line to Oracle. I get no error in SXMB_MONI, no error in the message mapping test, and no error in the Test configuration in the ID.
Here is the error I get in the RWB comm channel monitoring for my adapter:
<i>No "action" attribute found in XML document ("action" attribute missing or wrong XML structure)
MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure)
Exception caught by adapter framework: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure)
Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure).</i>
Here is my structure for the oracle receiver:
DTOracleReceiver_INSERT
TEMP_DATA_XI 1
action (attribute) xsd:string
access
NCODE xsd:string 1
VNAME xsd:integer 1
DDATE xsd:date 1
NPRICE xsd:decimal 1
LSTATES xsd:string 1
TEMP_DATA_XI is my table name in Oracle
action is set to constant "INSERT" in the message mapping.
When I look at the payload in the OracleReceiver adapter, this is what shows up:
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MTOracleReceiver_INSERT xmlns:ns0="http://test.com/jdbc">
- <TEMP_DATA_XI action="INSERT">
- <access>
<NCODE>200</NCODE>
<VNAME>Inserttest</VNAME>
<DDATE>2007-06-15 09:25:43.0</DDATE>
<NPRICE>20.00</NPRICE>
<LSTATES>test of JDBC receiver</LSTATES>
</access>
</TEMP_DATA_XI>
</ns0:MTOracleReceiver_INSERT>
Any thoughts or ideas on how to fix this error? Any help would be greatly appreciated.
Thanks,
JakeI now get a different error:
Unable to execute statement for table or stored procedure. 'TEMP_DATA_XI' (Structure 'STATEMENTNAME') due to java.sql.SQLException: ORA-00928: missing SELECT keyword
2007-06-19 10:03:54 Error MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'TEMP_DATA_XI' (structure 'STATEMENTNAME'): java.sql.SQLException: ORA-00928: missing SELECT keyword
2007-06-19 10:03:54 Error Exception caught by adapter framework: Error processing request in sax parser: Error when executing statement for table/stored proc. 'TEMP_DATA_XI' (structure 'STATEMENTNAME'): java.sql.SQLException: ORA-00928: missing SELECT keyword
2007-06-19 10:03:54 Error Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'TEMP_DATA_XI' (structure 'STATEMENTNAME'): java.sql.SQLException: ORA-00928: missing SELECT keyword.
My current datatype for the receiver is:
DTOracleReceiver_INSERT 1
STATEMENTNAME 1
TEMP_DATA_XI 1
action (attribute) xsd:string required
Table xsd:string 1
access 0:unbounded
NCODE xsd:string 1
VNAME xsd:integer 1
DDATE xsd:date 1
NPRICE xsd:decimal 1
LSTATES xsd:string 1
action is mapped to "INSERT"
Table is mapped to "TEMP_DATA_XI" -
Oracle jdbc driver spending 40 seconds to make connection to Oracle db 11g
we are using weblogic 10.3.3 and teh default Oracle11.1.0.7 Driver ojdbc6.jar to talk to Oracle db 11.2.0.1
After reviewing weblogic logs I see that it takes 50 secodns for each connection to db
HHere is a snippet (note I put in a 10 sec login dleay as i was experimenting, butt eh problem still occurs with or without login delay)
<Dec 21, 2010 1:28:19 AM GMT> <Info> <JDBC> <BEA-001516> <Connection Pool "acm_repository" connected to Database: "Oracle", Version: "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options".>
Dec 21, 2010 1:28:19 AM GMT> <Info> <JDBC> <BEA-001517> <Connection Pool "acm_repository" using Driver: "Oracle JDBC driver", Version: "11.1.0.7.0-Production".>
<Dec 21, 2010 1:28:19 AM GMT> <Info> <JDBC> <BEA-001132> <Initialized statement cache of size "10" for connection in pool "acm_repository".>
<Dec 21, 2010 1:28:19 AM GMT> <Info> <JDBC> <BEA-001066> <Delaying 10 seconds before making a acm_repository pool connection.>
<Dec 21, 2010 1:29:09 AM GMT> <Info> <JDBC> <BEA-001068> <Connection for pool "acm_repository" created.>
There is someting wrong in this environment
I donwloaded the _g version fo teh exact same driver and had weblogic use it so I could generate verbose logs
Here is a snippet fo teh oracle drivers verbose log file . If you notice the key parts
it seems like its spending 40 second to make the connection, goes into a setConnectionDuringExceptionHandling method and creates the connection
can someone shed light on what causes itto go into an exception state
This happens for each and every connection but only in one specific environment
we have other environments which seem towork fine with the exact same product versions except for this environment
Thank you for any guidance on troubleshooting this further
-Y
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection parseConnectionProperty_Object
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection readOCIConnectionPoolProperties
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection readConnectionProperties
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection initialize
TRACE_16: Enter: null, null, null
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection initialize
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Enter:
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Enter:
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Exit
Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.T4CConnection logon
**TRACE_16: Enter:**
**Dec 21, 2010 1:27:38 AM oracle.jdbc.driver.T4CConnection connect**
**TRACE_16: Enter: "10.135.3.80:1521:EPFDSQA"**
**Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.T4CMAREngine setConnectionDuringExceptionHandling**
**TRACE_16: Enter:**
**Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.T4CMAREngine setConnectionDuringExceptionHandling**
TRACE_16: ExitDec 21, 2010 1:28:18 AM oracle.jdbc.driver.DBConversion findDriverCharSet
TRACE_16: Enter: 178, 8100
Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.DBConversion findDriverCharSet
TRACE_16: return: 178
Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.DBConversion findDriverCharSet
TRACE_16: Exit
Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.DBConversion <init>
TRACE_16: Enter: 178, 178, 2000
Dec 21, 2010 1:28:18 AM oracle.jdbc.driver.DBConversion init
TRACE_16: Enter: 178, 178, 2000I would file an oracle jdbc bug to begin with, but I am guessing the driver is simply waiting
for the DBMS to respond, so yo may need a good DBA to see what the DBMS thinks is going
on at the time. I did hear of a case where the DBMS was doing some auditing, logging
some info during every login. This info was being written to an OS file which just happened
to be remote-mounted and would occasionally take 30 seconds, which caused connection
requests to timeout at the driver end.... WebLogic is just asking the driver for a connection
using your properties, so it's not involved directly with the problem.... -
Issue encountered when Login as sysdba role using Thin Oracle JDBC Driver
Hello all,
we are now considering to use Thin oracle JDBC driver to create database in our project, but we met one issue when we tried to connect to oracle as sysdba role using Thin driver, and it throws java.sql.SQLException: Io Exception: SO Exception was generated, I have found some tips on oracle jdbc website and it says :
How do I connect as SYSDBA or SYSOPER?
The only way to do this is to use the Properties object when connecting, rather than specifying the username and password as strings. Put the username into the "user" property, and the password into the "password" property. Then, put the mode into the "internal_logon" property. Something like the following:
Properties props = new Properties();
props.put("user", "scott");
props.put("password", "tiger");
props.put("internal_logon", "sysoper");
Connection conn = DriverManager.getConnection (url, props);
When connecting as SYSDBA or SYSOPER using the Thin driver, the RDBMS must be configured to use a password file. See "Creating and Maintaining a Password File" in the "Oracle Database Administrator's Guide".
So, i did execute orapwd command to create a password file and also set remote_login_passwordfile=execlusive in my initxxx.ora initial parameter file, however, when i tried to connect, it failed.
private static void createEmsdbDatabase(){
String url = "jdbc:oracle:thin:@localhost:1521:";
StringBuffer sqlStatement = new StringBuffer();
sqlStatement.append("create database xxx");
sqlStatement.append("maxdatafiles 254 ");
sqlStatement.append("maxinstances 8 ");
sqlStatement.append("maxlogfiles 32 ");
sqlStatement.append("character set UTF8 ");
sqlStatement.append("national character set UTF8 ");
sqlStatement.append("DATAFILE 'c:\\oracle\\xxx\\system01.dbf' SIZE 18M REUSE ");
sqlStatement.append("logfile 'c:\\oracle\\xxx\\redo01.log' SIZE 2M REUSE, ");
sqlStatement.append("'c:\\oracle\\xxx\\redo02.log' SIZE 2M REUSE, ");
sqlStatement.append("'c:\\oracle\\xxx\\redo03.log' SIZE 2M REUSE ");
try {
DriverManager.registerDriver(new OracleDriver());
Properties props = new Properties();
props.put("user", "sys");
props.put("password", "password");
props.put("database","xxx");
props.put("internal_logon", "sysdba");
Connection conn = DriverManager.getConnection(url, props);
Statement statement = conn.createStatement();
statement.executeUpdate(sqlStatement.toString());
statement.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
But what made me puzzled a lot is if i use OCI driver, it did work great, why??? guys, anybody knows, please give me some tips, thanks in advance.
regards,
Kaixuan @ Shanghaiclarify my question in detail:
Step 1 : create password file using orapwd command
Step 2 : create database instance using oradim command
Step 3 : login using sys as sysdba to startup database, e.g startup nomount pfile='...\initxxx.ora'
Step 4 : create database.
java code showing below:
private static void createEmsdbDatabase(){
String url = "jdbc:oracle:thin:@localhost:1521:";
StringBuffer sqlStatement = new StringBuffer();
sqlStatement.append("create database xxx ");
sqlStatement.append("maxdatafiles 254 ");
sqlStatement.append("maxinstances 8 ");
sqlStatement.append("maxlogfiles 32 ");
sqlStatement.append("character set UTF8 ");
sqlStatement.append("national character set UTF8 ");
sqlStatement.append("DATAFILE 'c:\\oracle\\xxx\\system01.dbf' SIZE 18M REUSE ");
sqlStatement.append("logfile 'c:\\oracle\\xxx\\redo01.log' SIZE 2M REUSE, ");
sqlStatement.append("'c:\\oracle\\xxx\\redo02.log' SIZE 2M REUSE, ");
sqlStatement.append("'c:\\oracle\\xxx\\redo03.log' SIZE 2M REUSE ");
try {
DriverManager.registerDriver(new OracleDriver());
Properties props = new Properties();
props.put("user", "sys");
props.put("password", "password");
props.put("database","xxx");
props.put("internal_logon", "sysdba");
Connection conn = DriverManager.getConnection(url, props);
Statement statement = conn.createStatement();
statement.executeUpdate(sqlStatement.toString());
statement.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
issue was met here, when i tried to login as sysdba using sys, and in my java code, i use Thin driver, it then thrus exception, but when OCI driver is used, it works great, i don't know why.
that is, when i use "jdbc:oracle:oci8:@" as database URL and then properties.put("database","xxx"), it works great. but, when i use "jdbc:oracle:thin:@localhost:1521:" as database URL and then properties.put("database","xxx"), it failed. hopefully, i have clarified my question clearly. thanks. -
Exception "not implemented for class oracle.jdbc.driver.T4CNumberAccessor"
Hello I'm having some troubles dealing with 'java.sql.Date' I'm working with express edition database and I have three classes(different packages)
1.Mapper
2.Objects Class
3.ConsoleTest
I need to get an arraylist of objects, some of which contain dates, but when try to do it I get this exception
"java.sql.SQLException: Invalid column type: getDate not implemented for class oracle.jdbc.driver.T4CNumberAccessor"
Do you have any idea how I can implement the getDate method for this T4CNumberAccessor
Here are the methods that I'm using
1.Mapper
public ArrayList<Object> getAllTaskAuctions(Connection con)
ArrayList<Object> l1 = new ArrayList<Object>();
String SQLString1 = "select * from taskauction natural join tasks";
PreparedStatement statement=null;
try
//=== get taskauctions natural join tasks
statement = con.prepareStatement(SQLString1);
ResultSet rs = statement.executeQuery();
while(rs.next())
l1.add(new TaskAuction(rs.getInt(1), rs.getInt(2), rs.getInt(3),
rs.getDate(4), rs.getDate(5), rs.getInt(6)));
l1.add(new Task(rs.getInt(1), rs.getInt(2), rs.getString(3),
rs.getString(4), rs.getString(5), rs.getString(6), rs.getInt(7)));
catch (Exception exc)
System.out.println("Fail in TaskAuctionMapper - getAllTaskAuctions");
System.out.println(exc);
return l1;
2.ConsoleTest class
Connection con;
public Connection getConnection(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:XE", "Project", "123" );
//username/password@[/]host[:port][service_name]
catch (Exception e)
{ System.out.println("fail in getConnection()");
System.out.println(e); }
return con;
public static void main(String[] args) {
ConsoleTest ct = new ConsoleTest();
TaskAuctionMapper tam1 = new TaskAuctionMapper();
ArrayList<Object> alt1 = tam1.getAllTaskAuctions(ct.getConnection());
Iterator<Object> itr1 = alt1.iterator();
while (itr1.hasNext())
TaskAuction taskauct = (TaskAuction) itr1.next();
//Problem, exception traced to TaskAuctionMapper
System.out.println(
"Task ID: " + taskauct.getTaskid()+ ", "+
"StartDate: "+ taskauct.getStartdate()+", "+
"User ID: " + taskauct.getUserid());
}Found the answer, I shouldn't use integers as parameters of column index in the result set, but instead use String to mark the fields :)
-
Problems when using absolute() on Oracle JDBC driver
Hi all,
I wrote some codes using JDBC to access a remote Oracle server. After got the resultset, I attempted to use absolute() method to move to a specific row index and got an error. Could anyone please help me to find out the cause and the solution?
Thanks in advanced,
** We have used driver package jdbc/lib/classes.zip in ORACLE 8.1.7
** The total of records in HEFKE000 table > 1000;
** The coding is following:
String url = null;
Connection conn = null;
ResultSet rs = null;
Statement stmt = null;
String query = "select * from HEFKE000";
String dbName = "HE_MI";
String hostName = "NTTD";
String userName = "HOKEN";
String passWord = "manager";
String dbDriver = "oracle.jdbc.driver.OracleDriver";
//Load the Driver
Class.forName(dbDriver);
//get connection
url = "jdbc:oracle:oci8:@NTTD";
//url = "jdbc:oracle:thin:@" + hostName + ":1521:" + dbName;
conn = DriverManager.getConnection (url, userName, passWord);
// It's faster when you don't commit automatically
conn.setAutoCommit (false);
// Create a Statement object so we can submit
// SQL statements to the driver
stmt = conn.createStatement();
// Submit a query, creating a ResultSet object
rs = stmt.executeQuery(query);
// Get the ResultSetMetaData. This will be used for the column headings
ResultSetMetaData rsmd = rs.getMetaData ();
// Get the number of columns in the result set
int numCols = rsmd.getColumnCount ();
int i;
if (rs.next() == rs.isFirst()) {
rs.absolute(100);
boolean more = rs.next ();
while (more) {
// Loop through each column, getting the
// column data and displaying
for (i=1; i<=numCols; i++) {
if (i > 1) {
System.out.print("|");
if (rs.getString(i) == null)
System.out.print("");
else
System.out.print(rs.getString(i));
output.println();
// Fetch the next result set row
more = rs.next ();
** The error:
Exception in thread "main" java.sql.SQLException: Invalid operation for forward
only resultset : absoluteThanks. However, after changed the codes as your suggestion and ran again, I got the following error:
Exception:
java.lang.OutOfMemoryError
<<no stack trace available>>
A note is that, the 'select * from HEFKE000' statement would get around 1,5 millions of records. So, the 'out of memory' above is for client side or for server side?
Thanks,
Maybe you are looking for
-
I just updated iTunes, and it completed successfully. Then I tried to open it, and it asked for the user agreement like normal. Then it wouldn't open, saying, "The file iTunes Library.itl cannot be read because it was created by a newer version of iT
-
Hello, Iam working on SRM system which is UNICODE,I have tos end the mail with pdf attachment from SRM system ,but the problem is i have to get the data from R/3 System(in which iam using CONVERT_OTFSPOOLJOB_2_PDF to convert the spool request number
-
HT201320 how do I sync my email form my "Mail" program on my powerbook to my iphone.
how do I sync my email accounts form my "Mail" program that are on my powerbook to my iphone. there used to be a tab in iTunes where all my emails were listed. where did this go?
-
Seeking help in extracting data from partitioned table"YEARWISE".
Hi Experts, I need a favour in extracting data YEARWISE like 'from 1999 to 2000. Table is partitioned with around 40 partitions, and data I want to extract with sign ',' separating columns.So that I can move it to application as text file directly. P
-
Why does Command+Z enable zoom sometimes?
I've tried to nail down exactly when and why this happens but have yet to figure it out. Usually happens (but not all the time) when I'm using the path tool and hit command+z to reverse a node I've created, but then the cursor swtiches to the magnify