4 Replies Latest reply on Apr 6, 2013 5:35 PM by rahul kaushik

    java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@......

    Thomas Chang Apprentice

      Hi,

       

      I have the foloinwg code:

      [code]

      public class CounterBean implements Counter {

          String name = "java:jboss/exported/CounterBean";

          String value = "JNDIExample instantiated at " + new Date().toString();

          private static final String ICFP_USER = "test";

          private static final String ICFP_PWD = "test";

          private static final String ICFP_URL = "jdbc:oracle:thin:@mydb:1521:jbona1";

       

              public String printCount(int countNumber) {

              ConnectOracleServer connServer = new ConnectOracleServer();

       

              try {

                  new javax.naming.InitialContext().rebind(name, value);

                 

                  connServer.dbConnect(ICFP_URL, ICFP_USER, ICFP_PWD);

                 

              } catch (NamingException e1) {

                  // TODO Auto-generated catch block

                  e1.printStackTrace();

              }

             

              System.out.println("Request from Client " + countNumber);

              String rt = new Integer(countNumber).toString();

              return "Response from server " + rt;

          }

      }

       

      [/code]

       

      and

       

      [code]

      public class ConnectOracleServer {

          public void dbConnect(String db_connect_string, String db_userid,

                  String db_password) {

              try {

                  Connection conn = DriverManager.getConnection(db_connect_string,

                          db_userid, db_password);

              } catch (SQLException e) {

                  // TODO Auto-generated catch block

                  e.printStackTrace();

              }

       

          }

      }

       

      [/code]

       

       

      My codes run well in Jboss AS 5 and 6. But not in Jboss AS 7. I got exception like:

       

      ...

      14:29:40,375 ERROR [stderr] (EJB default - 1) java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@raca2-vip:1521:jbona1

      14:29:40,376 ERROR [stderr] (EJB default - 1)   at java.sql.DriverManager.getConnection(DriverManager.java:602)

      14:29:40,376 ERROR [stderr] (EJB default - 1)   at java.sql.DriverManager.getConnection(DriverManager.java:185)

      14:29:40,377 ERROR [stderr] (EJB default - 1)   at com.my.app.ConnectOracleServer.dbConnect(ConnectOracleServer.java:11)

      14:29:40,377 ERROR [stderr] (EJB default - 1)   at com.my.app.CounterBean.printCount(CounterBean.java:25)

      14:29:40,377 ERROR [stderr] (EJB default - 1)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      14:29:40,377 ERROR [stderr] (EJB default - 1)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      14:29:40,377 ERROR [stderr] (EJB default - 1)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      14:29:40,378 ERROR [stderr] (EJB default - 1)   at java.lang.reflect.Method.invoke(Method.java:597)

      14:29:40,378 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

      14:29:40,378 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,378 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

      14:29:40,379 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

      14:29:40,379 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,379 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

      14:29:40,381 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,387 ERROR [stderr] (EJB default - 1)   at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

      14:29:40,388 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,388 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

      14:29:40,391 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,391 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      14:29:40,391 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

      14:29:40,391 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:227)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:303)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:189)

      14:29:40,392 ERROR [stderr] (EJB default - 1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:29:40,393 ERROR [stderr] (EJB default - 1)   at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)

      ...

       

       

      The Oracle driver ojdbc6-11.2.0.2.0.jar is saved under $JBOSS_HOME/standalone/lib/ext