Welcome Wonseok,
The default driver is the JDBC ODBC
driver because this is (well was) the only JDBC part of JDK (at least the sun
jdk). It is odd that your JVM is
getting an error trying to load the class.
In general I agree, the sun JDBC ODBC
driver is rarely used, perhaps the default should be changed to Derby, or
Oracle or MySQL, or perhaps just have no default. Technically the driver class is not always required, if the
driver has already been loaded in the JVM simply using the URL should be enough
to work. If you did not set either
a driver or a URL, then we should probably be throwing an error.
I'm not sure on the deployment stuff. My guess is that predeployment is
called before the application is deployed, such as through the agent. The application classes (and possibly
JDBC driver) do not yet exist, so cannot be referred to. Deployment in an application server may
also pass a default database to connect to, so we may not know the database
until deployment.
-----Original
Message-----
From: eclipselink-dev-bounces@xxxxxxxxxxx
[mailto:eclipselink-dev-bounces@xxxxxxxxxxx]On
Behalf Of Wonseok Kim
Sent: Tuesday, March 25, 2008
11:12 AM
To: eclipselink-dev@xxxxxxxxxxx
Subject: [eclipselink-dev] Hello
and question about Connector
Hello!
EclipseLink commiters
Some guys already know me, but I'd like to introduce me first.
I am Wonseok working at TmaxSoft (South Korea) and also a committer of TopLink
Essentials.
Finally I got time to look into EclipseLink code and I would like to participate
and contribute to EclipseLink project. Also our AS product(JEUS) which now
includes TLE has plan to incorporate/support EclipseLink as a default provider.
I'm happy to see this project is already mature (documentation also).
Apparently I will have numerous questions about code or anything. So please,
please shed light on me even I ask silly questions. :-)
Okay, here my first question goes.
While I'm setting up my test environment (transition from TLE), I got the
following NPE and this is definitely my mistake of not setting
eclipselink.jdbc.driver correctly - it was toplink.jdbc.driver :-)
Exception in thread "main"
java.lang.NullPointerException
at
sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:436)
at
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
at
java.sql.DriverManager.getConnection(DriverManager.java:582)
at
java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91)
at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:164)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:578)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:214)
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:234)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
This is misleading error(I met this error several time before). Looking into
Connector code, I don't understand two things.
First, why is JDBC-ODBC bridge driver used when there is no driver setting? I
don't believe this is useful default. IMO just throwing proper error is more
helpful.
In addition, why is a dummy DefaultConnector(with default ODBC driver setting) set to
DatasourceLogin at predeployment time? It doen't seem being used at all.
Then the DefaultConnector is updated with real properties with EntityManagerSetupImpl#updateLogins and updateLoginDefaultConnector() at deployment. Isn't it clear and better
to create and set DefaultConnector at deployment if JDBC properties are used
while checking them(error could be thrown at this time)? I had no problem when
I modified code like this. Is this right way?
P.S. I really appreciate your commitment and efforts toward open source! It's a
really win-win to everyone.
Best Regards
-Wonseok