Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protocol Violation Error

 
Bharat Agarwal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic