我试图运行一个使用休眠访问 MSSQL 服务器的 Java 桌面应用程序,但是在尝试连接时,它会引发异常,我真的不知道该怎么办,这是我的配置文件
<?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">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username"></property>
<property name="connection.password"></property>
<property name="connection.url">
jdbc:jtds:sqlserver://localhost/databasename;useNTLMv2=true
</property>
<property name="dialect">
ba.fit.utilities.FDialect_SqlServer
</property>
<property name="myeclipse.connection.profile">nova 3</property>
<property name="connection.driver_class">
net.sourceforge.jtds.jdbc.Driver
</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- Opcije printanja SQL koda u konzolnom prozoru-->
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="use_sql_comments">false</property>
<!--vrijednost "update" kreira tabele ako nepostoje, ali ih nece mijenjati ako ima potrebe-->
<property name="hibernate.hbm2ddl.auto">update</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>
<!-- mapirane klase koje trebaju biti "persistence" -->
<!--
-->
<mapping class="ba.fit.Tomo_seminar.model.Administrator" />
<mapping class="ba.fit.Tomo_seminar.model.BiografijaPosloprimca" />
<mapping class="ba.fit.Tomo_seminar.model.BiografijaPoslodavca" />
<mapping class="ba.fit.Tomo_seminar.model.Drzava" />
<mapping class="ba.fit.Tomo_seminar.model.Grad" />
<mapping class="ba.fit.Tomo_seminar.model.Kategorija" />
<mapping class="ba.fit.Tomo_seminar.model.KategorijaBiografija" />
<mapping class="ba.fit.Tomo_seminar.model.OcjenePoslodavca" />
<mapping class="ba.fit.Tomo_seminar.model.OcjenePosloprimca" />
<mapping class="ba.fit.Tomo_seminar.model.Poslodavac" />
<mapping class="ba.fit.Tomo_seminar.model.Posloprimaoc" />
<mapping class="ba.fit.Tomo_seminar.model.Projekt" />
<mapping class="ba.fit.Tomo_seminar.model.ProjektKategorija" />
<mapping class="ba.fit.Tomo_seminar.model.Racun" />
<mapping class="ba.fit.Tomo_seminar.model.StatusTuzbe" />
<mapping class="ba.fit.Tomo_seminar.model.StrucnaSprema" />
<mapping class="ba.fit.Tomo_seminar.model.Tuzba" />
<mapping class="ba.fit.Tomo_seminar.model.Uplatnica" />
<mapping class="ba.fit.Tomo_seminar.model.ZahtjevZaRadNaProjektu" />
<mapping class="ba.fit.Tomo_seminar.model.RadnoVrijeme" />
</session-factory>
</hibernate-configuration>
但我得到了这个例外
20:52:43,562 WARN SettingsFactory:109 - Could not obtain connection metadata
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
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.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at ba.fit.utilities.HibernateUtil.<clinit>(HibernateUtil.java:24)
at ba.fit.Tomo_seminar.persistence.PosloprimaocDAO.pronadji(PosloprimaocDAO.java:17)
at ba.fit.Tomo_seminar.services.servLogin.LoginPosloprimaoc(servLogin.java:31)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.do_btnLogin_widgetSelected(FrmLogin.java:142)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin$1.widgetSelected(FrmLogin.java:92)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.main(FrmLogin.java:44)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
... 20 more
20:52:46,015 ERROR SchemaUpdate:134 - could not get database metadata
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
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.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:27)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:127)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at ba.fit.utilities.HibernateUtil.<clinit>(HibernateUtil.java:24)
at ba.fit.Tomo_seminar.persistence.PosloprimaocDAO.pronadji(PosloprimaocDAO.java:17)
at ba.fit.Tomo_seminar.services.servLogin.LoginPosloprimaoc(servLogin.java:31)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.do_btnLogin_widgetSelected(FrmLogin.java:142)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin$1.widgetSelected(FrmLogin.java:92)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.main(FrmLogin.java:44)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
... 21 more
20:52:46,015 ERROR SchemaUpdate:165 - could not complete schema update
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
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.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:27)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:127)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at ba.fit.utilities.HibernateUtil.<clinit>(HibernateUtil.java:24)
at ba.fit.Tomo_seminar.persistence.PosloprimaocDAO.pronadji(PosloprimaocDAO.java:17)
at ba.fit.Tomo_seminar.services.servLogin.LoginPosloprimaoc(servLogin.java:31)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.do_btnLogin_widgetSelected(FrmLogin.java:142)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin$1.widgetSelected(FrmLogin.java:92)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at ba.fit.imeprojekta.ui.gui.v1.FrmLogin.main(FrmLogin.java:44)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
... 21 more
20:52:47,328 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 08S01
20:52:47,328 ERROR JDBCExceptionReporter:72 - Network error IOException: Connection refused: connect