-->
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.  [ 5 posts ] 
Author Message
 Post subject: Unable to connect to SQLServer database with hibernate
PostPosted: Thu May 15, 2008 6:23 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
Hibernate version:3.1.2

I am getting really frustrated here. I have an SQLServer db and an Oracle db.

I have a test using a simple JDBC connection and anothe test using hibernate. With Oracle settings all is fine in both tests.

With the SQLServer db the simple JDBC connection is fine.
Using hibernate I get:

15-05-2008 11:07:00 [main] WARN - SQL Error: 208, SQLState: S0002
15-05-2008 11:07:00 [main] ERROR - Invalid object name 'GROUPS'.

My properties are:
Code:
   hibernate.dfwv.connection.isolation=2
   hibernate.dfwv.max_fetch_depth=1
   hibernate.dfwv.dialect=org.hibernate.dialect.SQLServerDialect
   hibernate.dfwv.show_sql=true
   hibernate.dfwv.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver
   hibernate.dfwv.connection.url=jdbc:sqlserver://localhost;databaseName=mydb
   hibernate.dfwv.connection.username=sa
   hibernate.dfwv.connection.password=mypassword
   hibernate.dfwv.jdbc.batch_size=0


The stack trace is
Code:
15-05-2008 11:17:14 [main] DEBUG - could not execute query [select this_.ABB_GROUP_NAME as ABB1_27_0_, this_.VERSION as VERSION27_0_, this_.LAST_UPD as LAST3_27_0_, this_.DISPLAY_GROUP_NAME as DISPLAY4_27_0_ from GROUPS this_]
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'GROUPS'.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
   at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteQuery(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
   at org.hibernate.loader.Loader.doQuery(Loader.java:662)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2145)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
   at org.hibernate.loader.Loader.list(Loader.java:2024)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1552)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
   at org.springframework.orm.hibernate3.HibernateTemplate$5.doInHibernate(HibernateTemplate.java:520)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
   at org.springframework.orm.hibernate3.HibernateTemplate.loadAll(HibernateTemplate.java:516)
   at uk.co.formfill.dfcommon.data.dfwv.group.GroupDaoHibernate.getAllGroups(GroupDaoHibernate.java:61)
   at uk.co.formfill.dfcommon.data.dfwv.group.BillsGroupDaoHibernateIntegrationTest.testGetAllGroups(BillsGroupDaoHibernateIntegrationTest.java:64)
   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:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Top
 Profile  
 
 Post subject: some more info
PostPosted: Thu May 15, 2008 9:10 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
turning up the debugging I can see the following request from the SQLServer driver;

Code:
exec sp_tables  @table_qualifier = null, @table_owner = 'mydb', @table_name = '%' , @table_type = '''TABLE'''


If I run this directly in SQLServer it fails.
If I change it to:

Code:
exec sp_tables  @table_qualifier = null, @table_owner = 'dbo', @table_name = '%' , @table_type = '''TABLE'''


it works fine.

The database is definitely called 'mydb'.
The owner is dbo or DBO

Any clues on how to rectify this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 10:09 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I've had a similar problem on SQLServer, it turned out I was using a reserved name for my table.

Maybe "Groups" is such a reserved name, you could try using a different tablename, or specify a catalog in you mappings.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 10:24 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
GROUPS does look dodgy but it is not a reservedword.

I have many number of other tables and have the same problem.

Cheers.
Bill


Top
 Profile  
 
 Post subject: Re: Unable to connect to SQLServer database with hibernate
PostPosted: Thu Feb 14, 2013 6:49 am 
Newbie

Joined: Thu Feb 14, 2013 6:40 am
Posts: 1
i am using SQLSERVER 2008 and i am unable to connect .... mine error log



com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host ZA-PC/SQLEXPRESS, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1049)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:213)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:73)
at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:360)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.