wood burning stoves 2.0*
The moose likes JDBC and the fly likes Protocol Violation Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Protocol Violation Error" Watch "Protocol Violation Error" New topic
Author

Protocol Violation Error

Bharat Agarwal
Greenhorn

Joined: Jun 16, 2001
Posts: 21
Hi all,
I am getting the protocol violation error when I am trying to get the connection Object using getConnection method.........i m using jdk1.3 and oracle 8.1.7 and linux server.....and the driver i m trying to use is all java thin driver......i tried all the possible ways but could not get rid of the error....it is driving me nuts.....help is badly needed........
-Bharat
kshitij raval
Greenhorn

Joined: Oct 20, 2001
Posts: 15
Well the only issue which I consider when connecting to any database from Java is that of classpath. Other than that I have not encountered any protocol violation error. By the way just check out the access permission of the folder where you have stored your driver. Anyway I am just sending a small code. Hope this will help you.
import java.io.*;
import java.sql.*;
public class ConnectOracle{

public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
// net is the name of the service which you will find in listener.ora
Connection con = DriverManager.getConnection ("jdbcracle:thin:@192.9.200.135:1521:net", "scott", "tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
rs.next();
System.out.println(rs.getString(1)+", "+rs.getString(2));

rs.close();
st.close();
con.close();
}catch(Exception e){
System.out.println("ConnectOracle - main() : ");
e.printStackTrace();
}
} // main(), method
} // ConnectOracle, bean class

[This message has been edited by kshitij raval (edited October 20, 2001).]
Jane Zhen
Greenhorn

Joined: May 09, 2003
Posts: 1
I got the same error when I use kshitij raval greenhorn Member # 21786's code. Can somebody give me some help. Thanks a lot.
(Well the only issue which I consider when connecting to any database from Java is that of classpath. Other than that I have not encountered any protocol violation error. By the way just check out the access permission of the folder where you have stored your driver. Anyway I am just sending a small code. Hope this will help you.
import java.io.*;
import java.sql.*;
public class ConnectOracle{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
// net is the name of the service which you will find in listener.ora
Connection con = DriverManager.getConnection ("jdbc racle:thin:@192.9.200.135:1521:net", "scott", "tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
rs.next();
System.out.println(rs.getString(1)+", "+rs.getString(2));
rs.close();
st.close();
con.close();
}catch(Exception e){
System.out.println("ConnectOracle - main() : ");
e.printStackTrace();
}
} // main(), method
} // ConnectOracle, bean class

[This message has been edited by kshitij raval (edited October 20, 2001).]
)
ConnectOracle - main() :
java.sql.SQLException: Protocol violation
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:383)
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:651)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:168)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:103)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:148)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at ConnectOracle.main(ConnectOracle.java:12)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Protocol Violation Error