Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to database using JDBC on Glassfish3

Is there any way to check whether my Glassfish acctually see ojdbc6.jar ?

I'm working with Netbeans 7.2.1, with JSF 2, Glassfish 3.1.2 and Oracle 11g. I want to connecto to this database.

So first I need to create connection pool in my Glassfish. I open localhost:4848 set 5 things:

  1. Resource Type: javax.sql.DataSource
  2. Class name of the data source: oracle.jdbc.pool.OracleDataSource
  3. Property: "user"
  4. Property: "password"
  5. Property: "url"

Save, reset server (just for sure), ping.... and the error: Class name is wrong or classpath is not set for: oracle.jdbc.pool.OracleDataSource

What have I already done:

  1. First check for ojdbc jars. From my Oracle dir I copied every jar that has "ojdbc" in name into "C:\glassfish3\glassfish\domains\domain1\lib".

  2. Second, check url properity. Inside Netbeans, switch into Services tab, right click on Databases, New connection... set data to connect (first I have to add, jodbc6.jar.. so I add exactly the same file - from glassfish folder). It works! connection is ok. I looked at Netbeans database url - the same as my url in glassfish gui. I also tried url with \, but it didn't help.

So, what else can it be? Maybe no.1 is not ok. So this is my question: How can I check whether my Glassfish acctually see ojdbc6.jar?

EDIT. When I run Glassfish i get some warnings:

WARNING: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@704d54].

WARNING: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@704d54] from index [0]

WARNING: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@ed312d] from index [1]

like image 414
Marshall Avatar asked Nov 28 '22 02:11

Marshall


2 Answers

Copy all required jar files(ojdbc6.jar.....) to 'domains\domain1\lib\ext' folder. Then restart your glassfish. Then try to ping from glassfish, it will work

like image 146
Fathah Rehman P Avatar answered Dec 02 '22 15:12

Fathah Rehman P


"..But how do you know it is 'ext' folder? And not just 'lib'? One guy says lib, other ext.."

Making the JDBC Driver JAR Files Accessible To integrate the JDBC driver into a GlassFish Server domain, copy the JAR files into the domain-dir/lib directory, then restart the server. This makes classes accessible to all applications or modules deployed on servers that share the same configuration. For more information about GlassFish Server class loaders, see "Class Loaders" in GlassFish Server Open Source Edition Application Development Guide. If you are using an Oracle database with EclipseLink extensions, copy the JAR files into the domain-dir/lib/ext directory, then restart the server. For details, see "Oracle Database Enhancements" in GlassFish Server Open Source Edition Application Development Guide

From here

like image 40
nuamehas Avatar answered Dec 02 '22 16:12

nuamehas