Solved

multi-threading and JDBC Oracle 8i thin driver

Posted on 2002-03-06
5
417 Views
Last Modified: 2008-03-03
I would appreciate if anyone could explain this problem for me:

In my program I am creating a thread to insert records in dB, several threds are running at the same time to do tnhe same functionality . I don't know if this helps I am using JDBC Oracle 8i thin driver and multi-threading and keep getting this problem:


Protocol violation
java.sql.SQLException: Io exception: not in streaming mode
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
        at oracle.jdbc.driver.OracleStatement.freeLine(OracleStatement.java:4621)
        at oracle.jdbc.driver.OracleConnection.needLine(OracleConnection.java:1627)
        at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:412)
        at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:474)
        at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:383)

0
Comment
Question by:shakfan
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
kelfink earned 80 total points
ID: 6844856
If you are using one connectin for multiple threads, this is the problem.  Each concurrent thread needs its own connection.

TO reduce the cost of connecting for each thread, use a Connection Pool.  
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6846603
in addition to kelfink's comment, you can enclose the usage of the connection in your code:
synchronyzed (conn) {
// using the connection
}

Make sure that every peace of code, that uses shared connection is synchronyzed
0
 
LVL 5

Expert Comment

by:kelfink
ID: 6848702
While synchronizing might avoid the problem, it makes the multithreading capacity pretty worthless, unless the database activity is an insignificant portion of the time spend in the thread.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8681445
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to kelfink

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 105
Weekend adv creator 3 38
even odd program using while loop 3 40
tomcat administrtor 12 46
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question