This is  how to connect to MSQSQL Microsoft SQL Server using Java and Hibernate application?
Using Java Hibernate to connect to Microsoft SQL Server? Here is the world famous unknown gotcha
For those that don’t know, and you’re pulling out your hair? Ensure you do and check for:
on sql server  configuration manager, ensure services and connections
under TCPIP properties are enabled, as well as both dynamic TCP and
TCP ports are included of 1433 (listening port). this is for IP1, IP2,
and IPall
http://cashforlifetv.com/blog/index.php/2010/11/18/using-java-hibernate-to-connect-to-microsoft-sql-server-here-is-the-world-famous-unknown-gotcha/
Ensure you use the JDTS JDBC connector, not the Microsoft one as it has many bugs. Get the right connector at:
http://sourceforge.net/projects/jtds/files/
Also, here is a sample of what your hibernate.cfg.xml you should look like as well:
<hibernate-configuration>
<session-factory>
<!–<session-factory name=”java:comp/hibernate/SessionFactory”>
<session-factory name=”java:hibernate/SessionFactory”>Â –>
<!– Database connection settings –>
<property name=”connection.driver_class”>net.sourceforge.jtds.jdbc.Driver</property>
<property>jdbc:jtds:sqlserver://localhost:1433/YourDatabase</property>
<property>sa</property>
<property>password</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>
<!– Enable Hibernate’s automatic session context management –>
<property name=”current_session_context_class”>thread</property>
<!– Disable the second-level cache –>
<property name=”cache.provider_class”>org.hibernate.cache.NoCacheProvider</property>
<!– Echo all executed SQL to stdout –>
<property>true</property>
<!– Drop and re-create the database schema on startup –>
<!–<property name=”hbm2ddl.auto”>create</property> –>
<property name=”hbm2ddl.auto”>update</property>
Note you may need to use the host server’s IP address instead of localhost in case the server is remote. i.e.10.0.0.10
These tips should help you out to easily connect to SQL Server using Java’s Hibernate framework.
NOTE I now post my
TRADING ALERTS into my personal
FACEBOOK ACCOUNT and
TWITTER. Don't worry as I don't post stupid cat videos or what I eat!