Solved

multi-threading and JDBC Oracle 8i thin driver

Posted on 2002-03-06
5
429 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

697 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