Solved

multi-threading and JDBC Oracle 8i thin driver

Posted on 2002-03-06
5
406 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now