I try to connect to sql server 2005 with hibernate but it seem it has a problem, I wrote .cfg.xml file but it shown me an error about hibernate.proprties, I undersood that these two ways to connect with hibernate, then I wrote the hibernate.proprties file:
hibernate.connection.username=USER-8E1B173EC4\User hibernate.connection.password= hibernate.connection.url=jdbc:jtds:sqlserver://localhost:1433;DatabaseName=Babies hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver hibernate.dialect=org.hibernate.dialect.SQLServerDialect
the hibernate .cfg.xml file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=Babies</property> <property name="hibernate.connection.username">USER-8E1B173EC4\User</property> <property name="hibernate.connection.password"></property> <property name="dialect">org.hibernate.dialect.SQLServerDialect</property> <!-- Mapping files --> <property name="show_sql">true</property> <mapping resource="Test.hbm.xml?"/> </session-factory> </hibernate-configuration>
and then I have this error:
java.sql.SQLException: Network error IOException: Connection refused: connect
this is the same error when I tried to connect to sql server through java code directly, and the same error message then.
what is worng here? someone has a guide that explain how to connect the sql server through hibernate step by step, because I didn't found in the net. I use the jTDS driver 1.2.5
thanks for the help!
|