Skip to main content

Setup Glassfish v3 with MS SQLServer

10 replies [Last post]
bike
Offline
Joined: 2010-01-13

Yesterday upgraded netbeans 6.5 to 6.8 which comes with Glassfish v3 (I was used to Glassfish v2).

Following instructions from http://docs.sun.com/app/docs/doc/820-4495/beana?a=view I try to setup a MS SQLServer connection.

I have trouble finding the jar files: smbase.jar, smsqlserver.jar and smutil.jar. I did find msbase.jar, mssqlserver.jar and msutil.jar (and a message on the MS site that they are discontinued) and have those ms*.jar files in my domain1\lib folder.

When creating the connection_pool and pinging I keep getting:
Class name is wrong or classpath is not set for : com.sun.sql.jdbcx.sqlserver.SQLServerDataSource

My questions:
- Where can I find the smbase.jar, smsqlserver.jar and smutil.jar?
- Is the domain1\lib folder the right place to put them?
- Should I use another way to setup a connection to MS SQLServer?

Any help appreciated!

I use:
- GlassFish v3 (build 74.2)
- NetBeans IDE 6.8 (Build 200912041610)
- Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15
- Windows XP version 5.1 running on x86; Cp1252; nl_NL (nb)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bike
Offline
Joined: 2010-01-13

Not being successful at the MS and Sun sites for a driver I am glad to learn about the sourceforge one. I downloaded the zip but I cannot get it running. I am sure the information I am looking for is just a few clicks away, but I can not find it.

My questions are:
1. Is deploying simply putting the zip in the ..\lib\ext folder? Or do I change the zip to jar? Probably yet something else because I tried both and nothing happened after I restarted glassfish.
2. What resource type and datasource classname should I use in the connection pool? I tried javax.sql.DataSource with net.sourceforge.jtds.jdbc.Driver but "ping" gives me a similar classpath problem (Class name is wrong or classpath is not set for : net.sourceforge.jtds.jdbc.Driver)

Thanks for the help so far, Bert.

sm157516
Offline
Joined: 2005-03-28

I assume you have downloaded the jtds-1.2.5-dist.zip. Unzip this and copy the jtds-1.2.5.jar to the glassfishv3/glassfish/lib directory.

Start the domain and from the admin console when you try to create a new jdbc connection pool with restype "javax.sql.DataSource" and database vendor "jtds", in the next page, the datasource classname is automatically introspected. This is a feature only in GlassFish V3. If you are using GlassFish V2, you can use the classname "net.sourceforge.jtds.jdbcx.JtdsDataSource".

Hope this helps.

bike
Offline
Joined: 2010-01-13

That was very helpful! Good to know I can do something stupid like downloading the wrong zip... Other comments made it easy to setup.

I got "ping" now. No time today to continue unfortunately.

sroeper
Offline
Joined: 2010-01-04

I use this driver:
http://msdn.microsoft.com/en-ca/data/aa937724.aspx
sqljdbc4.jar contains a JDBC4.0 Driver which works with Glassfish v2.1.
Under Glassfish v3 I am able to make a new Pool and run the Ping command successful. Every attempt to inject a PersistenceContext and use it ends with an Exception:Unable to retrieve EntityManagerFactory for unitName null

Maybe my driver is still wrong configured, so if you get this to work, I would be interested in your setup.

Stefan
http://www.roeperweise.com

sroeper
Offline
Joined: 2010-01-04

Ok, at least I was successful now. The driver is the new jTDs 1.2.5, http://jtds.sourceforge.net/index.html

I deployed the driver to $glassfish_home/glassfish/domains/domain1/lib/ext and restarted the server. After deploying my App, the first Netbeans message was:
Initializing...
Deploying driver: $glassfish_home/glassfish/domains/domain1/lib/jtds-1.2.5.jar
So this seems to be the right location.

Stefan

http://www.roeperweise.com

sroeper
Offline
Joined: 2010-01-04

I still recognize strange behavior. If I deploy a simple EJB/Servlet Application which uses a datasource/pool created in the Admin Console, the deployment process creates a new Pool and modifies the JDBC Resource to use this new Pool. The new Pool name includes the Database name and the User name.

Database Server: MS SQLServer 2000
Database: pubs
User: SVApp
Driver: jTDS1.2.5

persistence.xml:

jdbc/jtssql
false

Name of JDBC Resource: jdbc/jtssql

Original Connection Pool: jtssqlpool

Created Connection Pool: jtds_sql_pubs_SVAppPool

From domain.xml:

Deleting the driverClass Attribute and new deployment recreates the driverClass Attribute. New added attributes are preserved.

What kind of mechanism is that?
Can please someone help?

sroeper
Offline
Joined: 2010-01-04

Found it!

During my tests I created a new Entity Class with the Wizard (Nw Entity Classes from Database...). Due the fact that my database connection does not work at that time, I had to enter values for the Database connection. This created a sun-resources.xml file inside the Setup directory which was executed every time I deployed my application.

I am not sure if this is intended behaviour of Netbeans, but I don't like it. If a JDBC Resource is already specified it should not be overwritten from the IDE deployment with some magically created resource files.

But nevertheless, I eventually solved my problem now. Thank you for being patient.

vbkraemer
Offline
Joined: 2003-09-03

The NB behavior is intentional. Many people are used to starting with an initial configuration, that they change from inside the IDE by editing the sun-resources.xml as they do development.

Once things are cast in stone, the sun-resources.xml file is NOT part of the shipped, deployable archive.

vbk

sm157516
Offline
Joined: 2005-03-28

You could place the jars in glassfish_home/lib or domains lib or domains/domain1/lib/ext directories.

Marina Vatkina

This document talks about special version of some JDBC drivers that are
available from Sun. You need to find jars and the DataSource class name
from the MS SQLServer site.

-marina

glassfish@javadesktop.org wrote:
> Yesterday upgraded netbeans 6.5 to 6.8 which comes with Glassfish v3 (I was used to Glassfish v2).
>
> Following instructions from http://docs.sun.com/app/docs/doc/820-4495/beana?a=view I try to setup a MS SQLServer connection.
>
> I have trouble finding the jar files: smbase.jar, smsqlserver.jar and smutil.jar. I did find msbase.jar, mssqlserver.jar and msutil.jar (and a message on the MS site that they are discontinued) and have those ms*.jar files in my domain1\lib folder.
>
> When creating the connection_pool and pinging I keep getting:
> [i]Class name is wrong or classpath is not set for : com.sun.sql.jdbcx.sqlserver.SQLServerDataSource[/i]
>
> My questions:
> - Where can I find the smbase.jar, smsqlserver.jar and smutil.jar?
> - Is the domain1\lib folder the right place to put them?
> - Should I use another way to setup a connection to MS SQLServer?
>
> Any help appreciated!
>
> I use:
> - GlassFish v3 (build 74.2)
> - NetBeans IDE 6.8 (Build 200912041610)
> - Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15
> - Windows XP version 5.1 running on x86; Cp1252; nl_NL (nb)
> [Message sent by forum member 'bike' (b.menting@amnesty.nl)]
>
> http://forums.java.net/jive/thread.jspa?messageID=380616
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net