9 Replies Latest reply: Dec 5, 2006 8:58 AM by 807607 RSS

    JDBC connection establishing

    807607
      package pooling;
      import java.sql.*;
      public class ConnectionClass  {
           
           public Connection getConnection() 
              {
                Connection connection=null;
                try
                 {
                
                     try{
                     Class.forName ("oracle.jdbc.driver.OracleDriver");
                     }
                     catch(Exception ex){
                          System.out.println("Cannot find database driver"+ex);     
                     }
                     String strDatabaseURL ="jdbc:oracle:thin:@10.152.67.36:1521:ADIDAS" ;
                     String strUserName = "rmasupp1";
                     String strPassword = "Infosys";
                     System.out.println("Inside get connection Metod");
                     try
                     {
                     connection =(Connection) DriverManager.getConnection(strDatabaseURL, strUserName, strPassword);
                     }
                     catch(Exception e)
                     {
                          System.out.println("While Crating Connection object"+e);
                     }
                     System.out.println("after establishing connection");
                }
                catch(Exception E)
                {     
                     System.out.println("Exception Inside get Connection"+E);               
                }
                return connection;     
              }
              
              public static void main(String args[])
              {
                ConnectionClass c=new ConnectionClass();
                Connection con=c.getConnection();
                System.out.print("connection object"+con);
              }
           
      }
      in the above code while creating connection object it is giving below exception

      While Crating Connection objectjava.lang.ArrayIndexOutOfBoundsException

      can anybody help me.

      Regards,
      ramvee
        • 1. Re: JDBC connection establishing
          807607
          Don't post duplicate requests. You could get answer to this question in your previous post.

          Attach full stack trace.
          • 2. Re: JDBC connection establishing
            807607
            Inside get connection Metod
            java.lang.ArrayIndexOutOfBoundsException
                 at oracle.security.o3logon.C0.r(C0)
                 at oracle.security.o3logon.C0.l(C0)
                 at oracle.security.o3logon.C1.c(C1)
                 at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
                 at oracle.jdbc.ttc7.O3log.<init>(O3log.java:289)
                 at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
                 at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:246)
                 at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
                 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
                 at java.sql.DriverManager.getConnection(DriverManager.java:512)
                 at java.sql.DriverManager.getConnection(DriverManager.java:172)
                 at pooling.ConnectionClass.getConnection(ConnectionClass.java:23)
                 at pooling.ConnectionClass.main(ConnectionClass.java:42)
            While Crating Connection objectjava.lang.ArrayIndexOutOfBoundsException
            after establishing connection
            connection objectnull
            • 3. Re: JDBC connection establishing
              807607
              Which driver are you using?
              Try using different user/password. If you have access to different oracle, test the code against it.
              • 4. Re: JDBC connection establishing
                807607
                java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
                     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
                     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
                     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
                     at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:260)
                     at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
                     at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
                     at java.sql.DriverManager.getConnection(DriverManager.java:512)
                     at java.sql.DriverManager.getConnection(DriverManager.java:172)
                     at pooling.ConnectionClass.getConnection(ConnectionClass.java:23)
                While Crating Connection objectjava.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
                     at pooling.ConnectionClass.main(ConnectionClass.java:42)
                • 5. Re: JDBC connection establishing
                  807607
                  You have an incompatible version of the Oracle JDBC driver. Go to www.oracle.com (or technet or whatever it's called) and look for a driver that is designed to be used with the Oracle server version you have.
                  • 6. Re: JDBC connection establishing
                    807607
                    I have tried with other datebase it is giving above exception

                    Can u please tell me why it is giving exception.When i am using from it won't give exception now why it is coming.

                    regards,
                    Ramesh
                    • 7. Re: JDBC connection establishing
                      807607
                      Sorry for the above two posts

                      when i am tried two connect with another database it is giving following error

                      Inside get connection Metod
                      java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
                           at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
                           at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
                           at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
                           at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:260)
                           at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
                           at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
                           at java.sql.DriverManager.getConnection(DriverManager.java:512)
                           at java.sql.DriverManager.getConnection(DriverManager.java:172)
                           at pooling.ConnectionClass.getConnection(ConnectionClass.java:23)
                      While Crating Connection objectjava.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
                           at pooling.ConnectionClass.main(ConnectionClass.java:42)

                      if i connect from server it won't give any exception but why now i am getting can anybody tell.

                      regards,
                      Ramvee
                      • 8. Re: JDBC connection establishing
                        807607
                        Check database name value (eg: ADIDAS).
                        • 9. Re: JDBC connection establishing
                          807607
                          Hi i have tried all these things still problem is coming

                          the exception is

                          Inside get connection Metod
                          java.lang.ArrayIndexOutOfBoundsException
                               at oracle.security.o3logon.C0.r(C0)
                               at oracle.security.o3logon.C0.l(C0)
                               at oracle.security.o3logon.C1.c(C1)
                               at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
                               at oracle.jdbc.ttc7.O3log.<init>(O3log.java:289)
                               at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
                               at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:246)
                               at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
                               at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)

                          I am using Oracle 9i database and JVM 1.4

                          Regards,
                          Ramesh