Solved

multi-threading and JDBC Oracle 8i thin driver

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 67
what is a "java.lang.System Property"   ? 20 57
java stored proc example 9 22
configure dependency in POM for new database 3 17
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

910 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

15 Experts available now in Live!

Get 1:1 Help Now