Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Posts
    6

    Unanswered: 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...

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    You cannot connect to another database from a Java routine; use federation.

  3. #3
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •