-->
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.  [ 3 posts ] 
Author Message
 Post subject: Programmatically connecting to SQL Server with Hibernate
PostPosted: Mon Jul 07, 2008 1:56 pm 
Newbie

Joined: Fri Mar 21, 2008 11:13 am
Posts: 2
Location: Richmond, VA
I've been all over looking for what I could be doing wrong. I've had an external cfg.xml file for a SQL Server 2005 database that has been working fine. I now need to bring it internal and programmatically set the values for my connection. I've attempted to set the configuration properties as I have with an Oracle connection, but it's just not making the connection. Any help is greatly appreciated.

Code:
configuration.setProperty("hibernate.connection.url", "jdbc:sqlserver://myserver");
configuration.setProperty("hibernate.connection.database", "db");
configuration.setProperty("hibernate.connection.username", "user");
configuration.setProperty("hibernate.connection.password", "pwd");


Code:
configuration.setProperty("hibernate.connection.url", "jdbc:sqlserver://myserver:1433;databaseName=db");
configuration.setProperty("hibernate.connection.username", "user");
configuration.setProperty("hibernate.connection.password", "pwd");


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:07 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Have you set the dialect properly?

http://www.hiberbook.com/HiberBookWeb/l ... hhibernate

Code:
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:25 pm 
Newbie

Joined: Fri Mar 21, 2008 11:13 am
Posts: 2
Location: Richmond, VA
Yes, I've set it to the appropriate dialect for SQL Server. And like I mentioned, it works fine if the values live in the hibernate.cfg.xml file. It's when I attempt to set them programmatically when I see the problems connecting to the data source.


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