java DB2 program error
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amar_Naik
Posted On:   Friday, March 10, 2006 02:24 PM

import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class T4DB2Connect { public static void main(String[] args) { try { // load the DB2 Driver System.out.println("1" ); Class.forName("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver"); // establish a connection to DB2 System.out.println("2" ); Connection db2Conn = DriverManager.getConnection("jdbc:db2://host ip address/db name","user id","passwd"); System.out.println("3" ); Statement st = db2Conn.createStatement();   More>>
			


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class T4DB2Connect {
public static void main(String[] args) {


try {
// load the DB2 Driver
System.out.println("1" );
Class.forName("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver");
// establish a connection to DB2
System.out.println("2" );
Connection db2Conn = DriverManager.getConnection("jdbc:db2://host ip address/db name","user id","passwd");
System.out.println("3" );
Statement st = db2Conn.createStatement();
System.out.println("4" );
String query =
"SELECT A.BJB_SCSJB_NM FROM CRYWTBT.TBSUC_JOBS A ,CRYWTBT.TBPRD_JOBS B, CRYWTBT.TBJOB_FREQ C WHERE A.BJB_NM ='CLR606AM' AND A.BJB_NM=B.BJB_NM AND B.BJB_NM=C.BJB_NM";
ResultSet resultSet = st.executeQuery(query);
System.out.println("Job " + " Average Salary");
System.out.println("-----" + " --------------");
while (resultSet.next()) {
String jobType = resultSet.getString(1);
System.out.println(jobType );
}
resultSet.close();
st.close();
db2Conn.close();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
}




i get the below error..
1
2
com.ibm.db2.jcc.b.DisconnectException:
Execution failed due to a distribution protocol error that caused deallocation of the conversation.
A DRDA Data Stream Syntax Error was detected. Reason: 0x3
at com.ibm.db2.jcc.a.ab.l(ab.java:1214)
at com.ibm.db2.jcc.a.ab.c(ab.java:363)
at com.ibm.db2.jcc.a.ab.v(ab.java:1447)
at com.ibm.db2.jcc.a.bb.a(bb.java:39)
at com.ibm.db2.jcc.a.b.e(b.java:1232)
at com.ibm.db2.jcc.a.b.b(b.java:1147)
at com.ibm.db2.jcc.a.b.q(b.java:931)
at com.ibm.db2.jcc.a.b.a(b.java:702)
at com.ibm.db2.jcc.a.b. (b.java:305)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:162)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at T4DB2Connect.main(T4DB2Connect.java:16)



when i tried to change the jdbc connection to
Connection db2Conn = DriverManager.getConnection("jdbc:db2os390://host ip address/db name","user id","passwd");
the error

com.ibm.db2.jcc.b.SqlException: Deprecated DB2 OS/390 protocol not supported by
T4: jdbc:db2os390://host ip address/db name
Use protocol jdbc:db2:
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:98)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at T4DB2Connect.main(T4DB2Connect.java:16)    <<Less
About | Sitemap | Contact