Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipse link DBWS -Connection is null(Connection is null when dbwsbuilder,cmd excecuted)
Eclipse link DBWS -Connection is null [message #1057981] Fri, 10 May 2013 06:14 Go to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
I am new to Eclipselink DBWS.

I have configured builder file, please find the attachment.

When i to run dbwsbuilder, connection is null and deployable artifact file are created but all the empty files.can any one help me?.

I have set the JAVA_HOME and DRIVER_CLASSPATH to the correct value and

Please find the complete details about the error which i am getting bellow

D:\eclipselink\utils\dbws>dbwsbuilder.cmd -builderFile D:\eclipselink\utils\dbws
\eclipselink-dbws.xml -stageDir D:\MySqlDriver\Outputs -packageAs wls emp.war
JDBC driver error: com.mysql.jdbc.Driver
Exception in thread "main" java.lang.IllegalStateException: Connection is null -
cannot retrieve JDBC metadata
at org.eclipse.persistence.tools.dbws.jdbc.JDBCHelper.getDatabaseMetaDat
a(JDBCHelper.java:780)
at org.eclipse.persistence.tools.dbws.jdbc.JDBCHelper.loadTables(JDBCHel
per.java:490)
at org.eclipse.persistence.tools.dbws.jdbc.JDBCHelper.loadTables(JDBCHel
per.java:481)
at org.eclipse.persistence.tools.dbws.BaseDBWSBuilderHelper.buildDbArtif
acts(BaseDBWSBuilderHelper.java:527)
at org.eclipse.persistence.tools.dbws.DBWSBuilder.build(DBWSBuilder.java
:391)
at org.eclipse.persistence.tools.dbws.DBWSBuilder.start(DBWSBuilder.java
:334)
at org.eclipse.persistence.tools.dbws.DBWSBuilder.start(DBWSBuilder.java
:190)
at org.eclipse.persistence.tools.dbws.DBWSBuilder.main(DBWSBuilder.java:
142)

Thanks in advance
Re: Eclipse link DBWS -Connection is null [message #1058009 is a reply to message #1057981] Fri, 10 May 2013 09:25 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
The generated files are empty since the builder can't connect to your database. Your builder file looks ok - make sure your database is running, verify username/password, etc.
Re: Eclipse link DBWS -Connection is null [message #1058014 is a reply to message #1057981] Fri, 10 May 2013 09:25 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
The generated files are empty since the builder can't connect to your database. Your builder file looks ok - make sure your database is running, verify username/password, etc.
Re: Eclipse link DBWS -Connection is null [message #1058017 is a reply to message #1057981] Fri, 10 May 2013 09:25 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
The generated files are empty since the builder can't connect to your database. Your builder file looks ok - make sure your database is running, verify username/password, etc.
Re: Eclipse link DBWS -Connection is null [message #1058021 is a reply to message #1057981] Fri, 10 May 2013 09:25 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
The generated files are empty since the builder can't connect to your database. Your builder file looks ok - make sure your database is running, verify username/password, etc.
Re: Eclipse link DBWS -Connection is null [message #1058174 is a reply to message #1058021] Mon, 13 May 2013 00:27 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
My database is running and user name and password is correct.

I am not able to make out what is the problem exactly.

May i get some help to identify the problem.
Re: Eclipse link DBWS -Connection is null [message #1058687 is a reply to message #1058174] Tue, 14 May 2013 13:15 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
Perhaps you can try the following bit of code to make sure everything is setup properly. Just make sure your MySQL connector jar is on the classpath.

-------------------

import java.sql.DriverManager;
import java.sql.SQLException;

public class Test {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException(cnfe);
}

String username = "root";
String password = "root";
String url = "jdbc:mysql://localhost:3306/parameterdatabasetest";

try {
DriverManager.getConnection(url, username, password);
} catch (SQLException sqlex) {
throw new RuntimeException(sqlex);
}
}
}
Re: Eclipse link DBWS -Connection is null [message #1059038 is a reply to message #1058687] Thu, 16 May 2013 07:54 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
I tried with the above code it connects to the database.

Problem is only when i try to connect to db using dbwsbuilder.cmd
Re: Eclipse link DBWS -Connection is null [message #1059073 is a reply to message #1059038] Thu, 16 May 2013 10:18 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
What version of EclipseLink are you using?
Re: Eclipse link DBWS -Connection is null [message #1059096 is a reply to message #1059073] Thu, 16 May 2013 11:59 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
I am using 2.4.2
Re: Eclipse link DBWS -Connection is null [message #1059102 is a reply to message #1059096] Thu, 16 May 2013 13:20 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
Have you set 'DRIVER_CLASSPATH' in the setEnv.cmd file? If you have, please make sure the path is correct. If not, refer to the following: http://www.eclipse.org/eclipselink/documentation/2.4/dbws/overview003.htm#sthref20


Re: Eclipse link DBWS -Connection is null [message #1059535 is a reply to message #1059102] Mon, 20 May 2013 07:08 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
I have copied MySql driver in one folder and set the folder path is DRIVER_CLASSPATH

Like :

Environment variable Name= DRIVER_CLASSPATH

Value=D:/Panisha (I have copied the MySql driver inside D:/Panisha)

Is it the right way to set DRIVER_CLASSPATH variable.

If i execute setEnv.cmd i could see path is updated properly
Re: Eclipse link DBWS -Connection is null [message #1059538 is a reply to message #1059535] Mon, 20 May 2013 07:29 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
I tried even by setting DRIVER_CLASSPATH variable value to D:/Panisha/mysql-connector-java-5.1.18-bin.jar. connection is still null

Seems like some how driver is not getting loaded.
Re: Eclipse link DBWS -Connection is null [message #1060218 is a reply to message #1059538] Thu, 23 May 2013 10:51 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
Your setEnv.cmd file should include the following, assuming "D:/Panisha/mysql-connector-java-5.1.18-bin.jar" is the correct path to your connector jar. Also, the file path you listed above has forward slashes, which shouldn't work on Windows. Perhaps open a command window and try "dir D:/Panisha/mysql-connector-java-5.1.18-bin.jar" and "dir D:\Panisha\mysql-connector-java-5.1.18-bin.jar".

============
@REM User MUST set DRIVER_CLASSPATH to point to their desired driver jar(s), such as JDBC and J2C. For example:
set DRIVER_CLASSPATH=D:\Panisha\mysql-connector-java-5.1.18-bin.jar

@REM
@REM Note: DRIVER_CLASSPATH should NOT contain any classes for your persistent business objects - these are
@REM configured in the Mapping Workbench project.
...
========
Re: Eclipse link DBWS -Connection is null [message #1061844 is a reply to message #1060218] Tue, 04 June 2013 06:49 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RN
Messages: 28
Registered: May 2013
Junior Member
Thanks David.

It worked after setting set DRIVER_CLASSPATH=D:\Panisha\mysql-connector-java-5.1.18-bin.jar in setEnv.cmd.
Re: Eclipse link DBWS -Connection is null [message #1061869 is a reply to message #1061844] Tue, 04 June 2013 08:51 Go to previous messageGo to next message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
Great!
Re: Eclipse link DBWS -Connection is null [message #1066442 is a reply to message #1057981] Tue, 02 July 2013 12:52 Go to previous messageGo to next message
Jérôme THIBAULT is currently offline Jérôme THIBAULT
Messages: 1
Registered: July 2013
Junior Member
Hello,

I have googled a lot on the same error :

JDBC driver error: com.mysql.jdbc.Driver
Exception in thread "main" java.lang.IllegalStateException: Connection is null - cannot retrieve JDBC metadata

which appears to be the same reported within this topic.

I checked the path to the mysql jar, and I'm taking out the last hair I have on this error.

Please find my setenv.sh file :

#!/bin/sh

# User MUST set DRIVER_CLASSPATH to point to their desired driver jar(s), such as JDBC and J2C. For example:
# DRIVER_CLASSPATH=/some_dir/jdbc/ojdbc14.jar:/some_other_dir/j2c/aqapi.jar; export DRIVER_CLASSPATH
DRIVER_CLASSPATH=/Users/jeromethibault/Downloads/eclipselink/utils/dbws/mysql-connector-java-5.1.25.jar; export DRIVER_CLASSPATH
# Note: DRIVER_CLASSPATH should NOT contain any classes for your persistent business objects - these are
# configured in the Mapping Workbench project.

# User MUST set INSTALL_JAVA_HOME to point a supported JRE. If none
# is provided for INSTALL_JAVA_HOME then the system JAVA_HOME
# value will be used
INSTALL_JAVA_HOME=$JAVA_HOME/bin

if [ "$JAVA_HOME" == "" ]; then
JAVA_HOME=$INSTALL_JAVA_HOME; export JAVA_HOME
fi



And my dbws-builder.xml configuration file :

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="censoredUrlByEclipseForums">
<properties>
<property name="projectName">dataClient</property>
<property name="logLevel">all</property>
<property name="username">root</property>
<property name="password">root</property>
<property name="url">jdbc:mysql://localhost:3306/networkNode_2</property>
<property name="platformClassname">org.eclipse.persistence.platform.database.MySQLPlatform</property>
<property name="driver">com.mysql.jdbc.Driver</property>
</properties>
<table catalogPattern="%" tableNamePattern="DCONTACT" />
</dbws-builder>

If you have any clues, I would love to hear some Smile

I run the dbws utility with this shell command :

./dbwsbuilder.sh -builderFile dbws-builder.xml -stageDir testEclipseDbws -packageAs wls test.war

Thanks in advance for your help,
Re: Eclipse link DBWS -Connection is null [message #1066807 is a reply to message #1066442] Thu, 04 July 2013 09:25 Go to previous message
David McCann is currently offline David McCann
Messages: 20
Registered: July 2009
Junior Member
Have you tried the code above to verify that your database info is correct (meaning a connection can be made using the info in the builder XML)?

Perhaps you can try the following bit of code to make sure everything is setup properly. Just make sure your MySQL connector jar is on the classpath.

-------------------

import java.sql.DriverManager;
import java.sql.SQLException;

public class Test {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException cnfe) {
            throw new RuntimeException(cnfe);
        }

        String username = "root";
        String password = "root";
        String url = "jdbc:mysql://localhost:3306/networkNode_2";

        try {
            DriverManager.getConnection(url, username, password);
        } catch (SQLException sqlex) {
            throw new RuntimeException(sqlex);
        }
    }
}

Previous Topic:JPQL Question - empty string
Next Topic:MOXy: Insert/Replacement scenario using Xpath
Goto Forum:
  


Current Time: Sat Jul 26 05:14:08 EDT 2014

Powered by FUDForum. Page generated in 0.03146 seconds