-->
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: [Solved] Can't read database schema with MS SQL
PostPosted: Tue Mar 10, 2009 11:47 am 
Newbie

Joined: Tue Mar 10, 2009 11:26 am
Posts: 6
Hello !

First of all, please exuse me if there's somewhere an answer to my questions, but after some hours on google i haven't found it. But you can prove me that i don't know how to search on google -in which case i guess i'll look for some tutorials :D.

Well, before going to the questionning part, you may wanna know which version of hibernate i use. In fact, i'm trying to run hibernate3 -hibernate tools 3.2.4 CR2- with eclipse ganymede and MS SQL Server 2005.

My issue is kinda simple, but very annoying. When i want to see my tables, in my hibernate configuration, i got this error : "Problem while reading database schema"
Here is the stack trace :
Code:
org.hibernate.exception.JDBCConnectionException: Getting database metadata
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
   at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:64)
   at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.caseForSearch(AbstractMetaDataDialect.java:163)
   at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:22)
   at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
   at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
   at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:114)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
   at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:105)
   at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:61)
   at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:105)
   at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://DBSRV.oneid.fr\\TEST;DatabaseName="rh";SelectMethod=cursor
   at java.sql.DriverManager.getConnection(Unknown Source)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
   at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getConnection(AbstractMetaDataDialect.java:122)
   at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:61)
   ... 11 more


I tried with some drivers (jTDS, Microsoft and an old Microsoft one that worked some days ago) and i got the same result; so, since i added thoses drivers -one at a time- in my project and my classpath i think my problem comes from the hibernate.cfg.xml
So here is this file in which i replaced the password by some stars ;):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.password">******</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://DBSRV.oneid.fr\\TEST;DatabaseName=rh;SelectMethod=cursor</property>
        <property name="hibernate.connection.username">apexrh</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    </session-factory>
</hibernate-configuration>


Please note that tere is no mapping for now, for i want to generate the classes from the tables.
I hope someone can help me to figure out what i have forgotten to configure.

Regards


Last edited by L.C. Wild on Wed Mar 11, 2009 5:32 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 4:39 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
java.sql.SQLException: No suitable driver found error occurs when the driver class was loaded but the syntax for the connection URL is not right.

I dont have much idea on MSSQL server connection urls. But just a wild guess. May be the issue is with the "\\" of "\\TEST". Try making it a single \. Escaping \ in xml doc is not need as you are entering it as free text and not an attribute value.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject: Thank you
PostPosted: Wed Mar 11, 2009 5:10 am 
Newbie

Joined: Tue Mar 10, 2009 11:26 am
Posts: 6
God ! That was this little thing. I do hate being stuck for hours because of such things.

So, this is working now; but i got some new issue identificating the user. But i think my problem comes from the server for i can't connect through SQL Server Management Studio either.

Well, i'll take a closer look at that after saying how much i'm glad you helped me : thank you !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 5:11 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Rating is welcome... ;-)

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 5:13 am 
Newbie

Joined: Tue Mar 10, 2009 11:26 am
Posts: 6
I was about to do so :)


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.