users@glassfish.java.net

Re: Toplink in Java SE, are there known issues connecting to MS SQL server?

From: <glassfish_at_javadesktop.org>
Date: Wed, 13 Aug 2008 13:07:39 PDT

> What is the connection string
jdbc:jtds:sqlserver://dbserver.xyz.uvw.de:1433/DATABASENAME

The persistance unit looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="DATABASENAMEPU" transaction-type="RESOURCE_LOCAL">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <class>desktopapplication3.Table1</class>
    <properties>
      <property name="toplink.jdbc.user" value="my_username"/>
      <property name="toplink.jdbc.password" value="my_password/>
      <property name="toplink.jdbc.url" value="jdbc:jtds:sqlserver://dbserver.xyz.uvw.de:1433/DATABASENAME"/>
      <property name="toplink.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
    </properties>
  </persistence-unit>
</persistence>

> and options you have specified in the Netbeans case and in the JPA cases?

A special feature is schema=dbo, but this is transferred correctly as an Annotation.
The persistence.xml is created by Netbeans - and the program works via VPN connection to our domain from an unmanaged Workstation!

> TopLink should just use the DriverManager
> DriverManager.getConnection(this.getConnectionString(), properties)
> to get the connection if you are using it to directly connect.

Perhaps there would be sent wrong properties when the user and machine are in a Windows Domain? I'm sure that I didn't set "domain=ourDomain". And username password are working with other (not Toplink) connections

> Also, what is the exception stack you get?

This is from the jtds-driver, the Microsoft sql driver produces a "there could be no TCP/IP connection established".

Application class desktopapplication3.DesktopApplication3 failed to launch
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Network error IOException: Connection reset
Error Code: 0
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
        at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:102)
        at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
        at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
        at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
        at desktopapplication3.DesktopApplication3View.initComponents(DesktopApplication3View.java:282)
        at desktopapplication3.DesktopApplication3View.<init>(DesktopApplication3View.java:36)
        at desktopapplication3.DesktopApplication3.startup(DesktopApplication3.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.sql.SQLException: Network error IOException: Connection reset
        at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:385)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
        at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:182)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:154)
        at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:100)
        ... 20 more
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:85)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:429)
        at java.net.Socket.connect(Socket.java:519)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:304)
        at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:255)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:310)
        ... 25 more
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class desktopapplication3.DesktopApplication3 failed to launch
        at org.jdesktop.application.Application$1.run(Application.java:177)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Network error IOException: Connection reset
Error Code: 0
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
        at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:102)
        at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
        at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
        at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
        at desktopapplication3.DesktopApplication3View.initComponents(DesktopApplication3View.java:282)
        at desktopapplication3.DesktopApplication3View.<init>(DesktopApplication3View.java:36)
        at desktopapplication3.DesktopApplication3.startup(DesktopApplication3.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        ... 8 more
Caused by: java.sql.SQLException: Network error IOException: Connection reset
        at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:385)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
        at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:182)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:154)
        at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:100)
        ... 20 more
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:85)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:429)
        at java.net.Socket.connect(Socket.java:519)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:304)
        at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:255)
        at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:310)
        ... 25 more

It looks like a real timeout, reached after 30 minutes - most likely caused by firewall or proxy settings ... but I don't know why and why only at Toplink?
[Message sent by forum member 'jiai' (jiai)]

http://forums.java.net/jive/thread.jspa?messageID=293158