• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java DB2 program

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i log in my mainframe environment using my user id and password ..
After that i go to QMF and fire my DB2 queries...

I want to read the DB2 tables , through my JAVA program..can anybody please guide on how i can od the connection to the DB2 database and what drivers are required..i am using Java 1.4

i know about connection through Oracle..
so if anybody can help me can you please let me know about DB2
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any help on this
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amar,
Connecting to db2 is the same as connecting to Oracle. But for mainframe, I think you need to use db2 connect.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IBM has many ways to connect distributed systems to mainframes. Your mainframe DB2 administrators ought to know some of the options. DB2 connect rings a bell, but nowadays I would not be shocked if you could set up a client-side alias for it just like an AIX or Windows hosted database.
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am trying to run a java db2 program. my db2 is in os/390.
below is the code
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 b2://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 " + "\tAverage Salary");
System.out.println("-----" + "\t--------------");
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();
}
}
}

the error is
1
2
com.ibm.db2.jcc.b.DisconnectException: Execution failed due to a distribution pr
otocol error that caused deallocation of the conversation. A DRDA Data Stream S
yntax 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 b2os390://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 b2os390://host ip address/db name
Use protocol jdbc b2:
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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic