Page 1 of 1

Mainframe java connectivity

PostPosted: Wed Feb 01, 2012 7:39 pm
by shuzzeus
How can i access db2 in mainframes with my application which is in java?How can i make this connectivity.i want to use db2 as backend which is in mainframes.

Re: mainframe java connectivity

PostPosted: Wed Feb 01, 2012 7:45 pm
by enrico-sorichetti
googling with java db2 connectivity returned more than 1000000 hits
what happened when You searched Yourself ?

Re: mainframe java connectivity

PostPosted: Wed Feb 01, 2012 8:14 pm
by shuzzeus
i did!! i found ways which uses some external drivers.
i made an app. in java, where i want to access that db2 database.
so i was wondering to do with soap/xml messages or any service with which i can access it.

Re: mainframe java connectivity

PostPosted: Wed Feb 01, 2012 8:18 pm
by shuzzeus
i created many app. but whole are in mainframes.in this,my app. is in windows and my database is in mainframes.so how can i access it?

Re: mainframe java connectivity

PostPosted: Thu Feb 02, 2012 9:07 pm
by Ed Goodman
You would first need to find out which of the many many ways of doing this your site has decided to support. On the mainframe side, they may have implemented JDBC connectors, or maybe a DataBean interface, or maybe an ODBC-type interface. Like you said, there are a lot of ways to do it.

However, if you pick a different one than the folks running them mainframe picked, you won't get connected.

Ask around at your shop and find out what other mainframe apps are sending data to java apps, then do whatever they did. The only thing I can tell you with any certainty is that you aren't going to like it. No matter what they used, you're going to think they should have used something else.

Also, don't confuse the connection layers with the tools that work on them. We just went through that this week. I was hearing things like "this is how this system passes data" when if fact, it was how the WebSphere wizard works. Once you looked at the code the wizard generated, you could see what was really happening.

Re: mainframe java connectivity

PostPosted: Fri Feb 03, 2012 1:53 pm
by shuzzeus
ED Goodman:

Thanks for your reply.
actually my all application were in same platform.this new application i never developed.i am developing it first time.i know many of sites using web interface in java/.net/php uses mainframe as backend but no idea about their technical connectivity.i want to know how can i go for this application (web page in front and mainframe db2 as backend).

Re: mainframe java connectivity

PostPosted: Fri Feb 03, 2012 10:01 pm
by Ed Goodman
I get that you are doing this for the first time. What I'm telling you is that for that particular mainframe where your DB2 is stored, it is NOT the first time someone needed to do it. Therefore, that mainframe has already (probably) created a conduit that you should use. You need to research your site specifically and find out what has already been installed to be used.

Once you know that they are using a given connectivity method, then you can find out how to do the Windows side of it. You'll use the Windows method that matches the method that is already working on your mainframe.

Re: mainframe java connectivity

PostPosted: Mon Feb 20, 2012 10:25 am
by jaggz
Hello Shuzzeus,

You can get this done by installing a driver(Type 4) Connection. There is book on " Application Programming guide and Reference for Java - SC18-7414-05". You can also review on JZOS which comes with JAVA install pack(/usr/lpp/java/j6_0_1).

This code will connect the DB2 :-

 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.DriverManager;
 import java.sql.Connection;
 import java.sql.SQLException;
 public class Sample
 {
   public static void main(String args[]) throws ClassNotFoundException
      {
         System.out.println("CONNECTING TO DATABASE");
         try
         {
         String locale1 = System.getProperty("user.language");
         System.out.println("The Locale of the system is:"+locale1);
         String useName = System.getProperty("user.name");
         System.out.println("The User of the system is: "+useName);
               Class.forName("com.ibm.db2.jcc.DB2Driver");
               String url="jdbc:db2://x.x.xxx.x:446/DB2LOCATION";

               String user="CUSTOM1";
               String password="abc123";
        Connection con=DriverManager.getConnection(url,user,password);
               PreparedStatement psmt=null;
               ResultSet rs=null;
               if (con != null)
                {
                   System.out.println("CONNECTED TO DB");
                   psmt = con.prepareStatement("SELECT * FROM STUDENT");
                   rs = psmt.executeQuery();
                   if (rs != null)
                   {
                     System.out.println("FETCHING");
                     while (rs.next())
                     {
                       System.out.println(rs.getString(2));
                     }
                   }
                }
               else
               {
                  System.out.println("NOT CONNECTED");
               }
           }
          catch(SQLException e)
          {
              e.printStackTrace();
          }
       }
    }


HTH
Jaggz

Re: Mainframe java connectivity

PostPosted: Mon Jul 26, 2021 1:45 pm
by ashima08
The Java program would use your favorite SOAP (or MQ) infrastructure to communicate with the CICS/COBOL program. For option 2, your CICS/COBOL program would have to be coded to be "web-aware." The CICS/COBOL program would have to use the WEB EXTRACT, WEB RECEIVE, and WEB SEND APIs to communicate with the Java program.

Re: Mainframe java connectivity

PostPosted: Mon Jul 26, 2021 7:08 pm
by Terry Heinze
Did you notice that you replied to a 9 year old topic?