-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Hiberntate conexion with Microsoft SQL Server 2000
PostPosted: Fri Jun 23, 2006 7:02 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Hello guys
(sorry for my grammar)
i am a Linux user and developer and just beginner and working with Hibernate
i have a system with Java and MySql4.1.X that works fine with
Hibernate 3.1

my boss need the system now in windows xp/sp2 but for
Microsoft SQL Server 2000

well i have already download and installed the driver Setup.exe SP2
(one click and more in Next Buttons and end)

and in the project i changed the hibernate.cfg.xml
to this
Hibernate version:3.1

Mapping documents:
<!-- Database connection settings -->

<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="connection.url">jdbc:microsoft:sqlserver://1E1;DatabaseName=MyDBName;SelectMethod=cursor</property>

<property name="connection.username">myuser</property>

<property name="connection.password">myprivatepassword</property>



<!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property>



<!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
and more ....

well when i "run" my "ant" i have this nice error :p
how is obvious is related with the silly driver
how i can resolve this guys????

i forgett some step???

and why in the
hibernate-3.1/etc/hibernate.properties
appear this
## Microsoft Driver (not recommended!)

#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver

#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor

so i can work woithout the driver????
how????
and how i can make the connection without the url????

i am not a windows user and developer
i am lost here

thanks a lot for advanced

Full stack trace of any exception that occurs:
[java] 17:30:18,997 FATAL DriverManagerConnectionProvider:65 - JDBC Driver class not found: com.microsoft.jdbc.sqlserver.

SQLServerDriver

[java] java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

[java] Initial SessionFactory creation failed.org.hibernate.HibernateException: JDBC Driver class not found: com.microsof

t.jdbc.sqlserver.SQLServerDriver

[java] Exception in thread "main" java.lang.ExceptionInInitializerError

[java] at com.jordan.dao.hibernate.util.MyHibernateUtil.<clinit>(Unknown Source)

[java] at com.jordan.dao.hibernate.NivelDesempenoADO.fillDB(Unknown Source)

[java] at manolo.main(Unknown Source)

[java] Caused by: org.hibernate.HibernateException: JDBC Driver class not found: com.microsoft.jdbc.sqlserver.SQLServerDr

iver

[java] at java.security.AccessController.doPrivileged(Native Method)

[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

[java] at java.lang.Class.forName0(Native Method)

[java] at java.lang.Class.forName(Class.java:164)

[java] at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)

[java] at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)



[java] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124

)

[java] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)



[java] at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)

[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)

[java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)

[java] at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:66)



[java] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124

)

[java] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)



[java] at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)

[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)

[java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)

[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

[java] ... 3 more

[java] Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

[java] at java.security.AccessController.doPrivileged(Native Method)

[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

[java] at com.jordan.dao.hibernate.util.MyHibernateUtil.<clinit>(Unknown Source)

[java] at com.jordan.dao.hibernate.NivelDesempenoADO.fillDB(Unknown Source)

[java] at manolo.main(Unknown Source)

[java] at java.lang.Class.forName0(Native Method)

[java] at java.lang.Class.forName(Class.java:164)

[java] at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)

[java] at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)



[java] ... 9 more

[java] Java Result: 1



BUILD SUCCESSFUL

Total time: 18 seconds



Name and version of the database you are using:
Microsoft SQL Server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 7:27 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver


include the driver jar in buildpath

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 7:28 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

include the driver jar on the buildpath ;)

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 10:34 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
scarface wrote:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

include the driver jar on the buildpath ;)


so the setup.exe can generate a .jar :p ??????

well i dont think so

i dont use windows

thanks anyway


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 10:48 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
hello

ok man u was right, ok let me test the connection
and of course i will u give your credit!!!!

thanks a lot!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 1:10 am 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Hello again
(sorry for my grammar)
i did an update with the driver, now is SP3 (same probelm with SP2)
now i have this problem

please check the url (the first use / and the second \)
i saw other forums, but without a right solution and
i read the documentation of microsoft, my tcp/ip port 1433 is in the
list of the protocols that can be used and my firewall is turn off

please, how i can resolve this

Thanks a lot for your time
p.d:the url info was changed for security reasons of the company (i show an equivalent patron)

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>

<property name="connection.url">jdbc:microsoft:sqlserver://NAMEMACHINE-D3E94C/SERVERNAMESQL:1433;DatabaseName=MyTestDataBase;SelectMethod=cursor</property>

<property name="connection.username">SomeUser</property>

<property name="connection.password">SomePassword</property>



<!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property>



<!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>





[java] 23:23:31,602 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1

[java] 23:23:31,622 INFO DriverManagerConnectionProvider:45 - autocommit mode: false

[java] 23:23:31,652 INFO DriverManagerConnectionProvider:80 - using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver

at URL: jdbc:microsoft:sqlserver://NAMEMACHINE-D3E94C/SERVERNAMESQL:1433;DatabaseName=MyTestDataBase;SelectMethod=cursor

[java] 23:23:31,652 INFO DriverManagerConnectionProvider:86 - connection properties: {user=SomeUser, password=****}

[java] 23:23:34,186 WARN SettingsFactory:103 - Could not obtain connection metadata

[java] java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

[java] at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

[java] at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)

[java] at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)

[java] at java.sql.DriverManager.getConnection(DriverManager.java:525)

[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)

[java] at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java

:110)

Second Way

<property name="connection.url">jdbc:microsoft:sqlserver://NAMEMACHINE-D3E94C\SERVERNAMESQL:1433;DatabaseName=MyTestDataBase;SelectMethod=cursor</property>

<property name="connection.username">SomeUser</property>

<property name="connection.password">SomePassword</property>



<!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property>



<!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

[java] java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The requested instance is either invalid or not

running.

[java] at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

[java] at com.microsoft.jdbc.sqlserver.tds.TDSConnection.mapInstanceNameToPort(Unknown Source)

[java] at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)

[java] at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)

[java] at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)

[java] at java.sql.DriverManager.getConnection(DriverManager.java:525)

[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)

[java] at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java

:110)

[java] at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderCon

nectionHelper.java:27)

[java] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:178)

[java] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:131)

[java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)

[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)

[java] at com.jordan.dao.hibernate.util.MyHibernateUtil.<clinit>(Unknown Source)

[java] at com.jordan.dao.hibernate.NivelDesempenoADO.fillDB(Unknown Source)

[java] at manolo.main(Unknown Source)

[java] 23:31:28,848 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: HY000

[java] 23:31:28,848 ERROR JDBCExceptionReporter:72 - [Microsoft][SQLServer 2000 Driver for JDBC]The requested instance is

either invalid or not running.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 7:32 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
The error is in your JDBC path. I'd recommend you trying to connect directly via DriverManager.getConnection(...) with this path.

The path you must give isn't a problem concerning Hibernate, but JDBC (the underlying layer). So I think the problem comes only from here, so should be very simple to resolve.

Look a the SQL-Server/JDBC doc to see how the url for a jdbc connection should be written.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 12:13 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
hello

<property name="connection.url">
jdbc:microsoft:sqlserver://SERVERNAMESQL:1433;DatabaseName=MyTestDataBase;SelectMethod=cursor</property>


nothing

inclusive why i can't see the service in the netstat??????

i think that is the reason,but the protocol tcp/ip is in the "Enabled Protocols list"
in the SQL Server Network Utility (svrnetcn.exe).

how i can enable this???

damn i hate windows!!!!!!!!

thanks for your time


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 6:29 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Where is located your sql server ? On your machine ?

Please try what I said : accessing your server directly through JDBC. Hibernate is just using it, so if it doesn't work, Hibernate can't work.

It's very simple to test : http://support.microsoft.com/default.as ... -us;313100

Are you sure your URL is ok ?
jdbc:microsoft:sqlserver://SERVERNAMESQL:1433;DatabaseName=MyTestDataBase;SelectMethod=cursor

Is SERVERNAMESQL an existing name of machine in your network (known by DNS) ?

If the DBMS is not on your own machine, I'd do that :
* Verify I can ping SERVERNAMESQL within cmd
* Test that I can access the 1433 port via telnet
* Test that with a sqlserver client I can browse the wanted database.

If you don't want to lose your time, you really should proceed this way. In fact, this way, you will be sure of what is working. If all of this is working, then you will have to concentrate on your java code, not before...

OK ?

PS : Don't ask too specific questions about sqlserver. I never used this server. I know JDBC very well and Hibernate correctly, that's all. :-)

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 8:31 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Hello

(sorry for my grammar)



thanks for the help and specially for the link, really thanks a lot

well i copy the code and make a .java file



i put the 3 jars of the jdbc driver in the CLASSPATH



when i try to execute the simple example of Microsoft in my home (yes a local machine)



i receive this nice error :p (the same error that in the company )

(i only add a simple line "only" to show the complete url)



E:\PRUEBAS\CONEXION>a



E:\Pruebas\Conexion>javac *.java



E:\Pruebas\Conexion>java Connect

jdbc:microsoft:sqlserver://SECTION1-D3E94C/OPERACIONESSQL:1433;databaseName=pubs;selectMethod=cursor;

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)

at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)

at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)

at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)

at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at Connect.getConnection(Connect.java:29)

at Connect.displayDbProperties(Connect.java:46)

at Connect.main(Connect.java:82)

Error Trace in getConnection() : [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

Error: No active Connection



E:\PRUEBAS\CONEXION>



well , about this Error: No active Connection <---- how i can activate????.



how i mentionated in the old posts, i have enabled the tcp/ip protocol with port 1433

in "Server Network Utility" but no appear in the "netstat report"



in the "SQL Server Enterprise Manager"

in "Servers of Microsoft SQL Server" and "Group of SQL Server" (i translated, i have the program in spanish )

my unique "server with all the dababases that have by default is"

"SECTION1-D3E94C\OPERACIONESSQL (Windows NT)" <--- with \



i try with some ways with the url



SECTION1-D3E94C/OPERACIONESSQL

SECTION1-D3E94C\OPERACIONESSQL (error :p)

OPERACIONESSQL

SECTION1-D3E94C





well, you are the expert and i need your knowledge, what should be the correct url?????

remember that i dont work with windows, i read other tutorials about of the port 1433,

inclusive i putted the sqlserver in the list of exceptions of the firewall of the same windows

but never appear in the netstat report, how an actuve connection.





so , please, how i can resolve this????



dont worry, i will give you 2 credits :p





and again thabks a lot for your time


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 4:16 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Dr Pompeii wrote:
thanks for the help and specially for the link, really thanks a lot

well i copy the code and make a .java file

i put the 3 jars of the jdbc driver in the CLASSPATH

when i try to execute the simple example of Microsoft in my home (yes a local machine)


Here's the url you indicated :
Quote:
jdbc:microsoft:sqlserver://SECTION1-D3E94C/OPERACIONESSQL:1433;databaseName=pubs;selectMethod=cursor;


So if you're on a local machine, are you sure the name of your machine is "SECTION1-D3E94C" ? If the server if on your machine, you should specify "localhost" here (see http://support.microsoft.com/default.as ... s;313100#4 example).

Try and let me know what it does.

Dr Pompeii wrote:
Error Trace in getConnection() : [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

Error: No active Connection

E:\PRUEBAS\CONEXION>

well , about this Error: No active Connection <---- how i can activate????.

well, you are the expert and i need your knowledge, what should be the correct url?????

remember that i dont work with windows, i read other tutorials about of the port 1433, inclusive i putted the sqlserver in the list of exceptions of the firewall of the same windows but never appear in the netstat report, how an actuve connection.

So , please, how i can resolve this????


I don't know about sqlserver configuration as I said. Try localhost instead first. If it still doesn't work, download a sqlserver client and try to connect with this app.

Also, try to use the quote and code tags to clarify your messages (and don't do too much newlines) :).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 2:23 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Hello
(sorry for my grammar)

thanks again for your time

about this

Here's the url you indicated :
jdbc:microsoft:sqlserver://SECTION1-D3E94C/OPERACIONESSQL:1433;databaseName=pubs;selectMethod=cursor;

yes you right but...
i said this

in the "SQL Server Enterprise Manager"
in "Servers of Microsoft SQL Server" and "Group of SQL Server" (i translated, i have the program in spanish )
my unique "server with all the dababases that have by default is"
"SECTION1-D3E94C\OPERACIONESSQL (Windows NT)" <--- with \

i try with some ways with the url
SECTION1-D3E94C/OPERACIONESSQL
SECTION1-D3E94C\OPERACIONESSQL (error :p)
OPERACIONESSQL
SECTION1-D3E94C

of course instead of use the localhost i use or try to work with some combinations (without positive results)
but i forget said that i used the "localhost", with the same sad result

anyway i will follow your suggestion about of the sql client

i will burn Microsoft , even the OS can help me :p
lol

thanks again


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.