If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Java Stored Procedure on Server Remote. Is it Possible?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-27-11, 19:41
acremex acremex is offline
Registered User
 
Join Date: Dec 2011
Posts: 6
Java Stored Procedure on Server Remote. Is it Possible?

I'm trying to make Remote Procedure This is my code to create procedure.
Code:
CREATE PROCEDURE SIZE (OUT TAM INTEGER)
   EXTERNAL NAME 'DIRECTE.SIZE'
   LANGUAGE JAVA PARAMETER STYLE JAVA;
Java Class
Code:
public class DIRECTE {
 
   public static void SIZE (int[]wrkcrsize){
    Connection conexion;
        int i=100; 
       try {
       // Cargar el Controlador JDBC de DB2 de tipo 2 con DriverManager
            Properties connectProperties = new Properties();
          
            connectProperties.put("user", "remoteuser");
            connectProperties.put("password", "remotepass");
            connectProperties.put("databaseName","remotebd");
            connectProperties.put("serverName","hostremote");
            connectProperties.put("portNumber","50000");

            Class.forName("com.ibm.db2.jcc.DB2Driver");
//Next line causes an error            
conexion = DriverManager.getConnection("jdbc:default:connection",connectProperties);
        
            conexion.setAutoCommit(false);
        
            ResultSet Registros = null;
       
            String sql1 = "SELECT COUNT(*) "
                + "FROM somsoc";
       
            Statement SentenciaSQL = conexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            Registros = SentenciaSQL.executeQuery(sql1);
            Registros.next();
            wrkcrsize[0] = Registros.getInt(1);
        SentenciaSQL.close();
        conexion.commit();
        conexion.close();
        } catch (ClassNotFoundException e) {
            System.out.println("Class not found");
            System.out.println(e);
     
        } catch (SQLException e) {
            System.out.println(e.getErrorCode());
            System.out.println(e);
          
        }  
   }
if I use local data everything works perfect, when I test the java class and netbeans o cmd with >>java "classgenerate.class" that work in local and remote...
Reply With Quote
  #2 (permalink)  
Old 12-28-11, 00:06
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You cannot connect to another database from a Java routine; use federation.
Reply With Quote
  #3 (permalink)  
Old 12-29-11, 11:43
acremex acremex is offline
Registered User
 
Join Date: Dec 2011
Posts: 6
how can I do?

Quote:
Originally Posted by n_i View Post
You cannot connect to another database from a Java routine; use federation.
There is some manual or tutorial that shows how to do it with two iseries serves?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On