Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在eclipse中为sqlexpress 2012配置j2ee hibernate配置文件_Java_Eclipse_Hibernate_Jdbc - Fatal编程技术网

Java 在eclipse中为sqlexpress 2012配置j2ee hibernate配置文件

Java 在eclipse中为sqlexpress 2012配置j2ee hibernate配置文件,java,eclipse,hibernate,jdbc,Java,Eclipse,Hibernate,Jdbc,我需要配置hibernate.cfg.xml以连接到sql express 2012 我正试图用hibernate向导工具实现这一点,但它根本没有连接 在我的eclipse项目中,右键单击project New>Hibernate配置文件(cfg.xml)。 单击next,然后单击“从连接获取值” 新建配置文件,在“新建连接配置文件”窗口中,我选择了“SQL Server” 接下来,在驱动程序下拉列表中,我单击了“New Deriver Definition”按钮,并在“New Deriver

我需要配置hibernate.cfg.xml以连接到sql express 2012

我正试图用hibernate向导工具实现这一点,但它根本没有连接

在我的eclipse项目中,右键单击project New>Hibernate配置文件(cfg.xml)。 单击next,然后单击“从连接获取值”

新建配置文件,在“新建连接配置文件”窗口中,我选择了“SQL Server”

接下来,在驱动程序下拉列表中,我单击了“New Deriver Definition”按钮,并在“New Deriver Definition”窗口中选择了“Microsoft SQL Server 2014 JDBC驱动程序”

在JAR列表选项卡中,我添加了我从中下载的“sqljdbc4.JAR”

…在属性选项卡中,我以这种方式设置属性

单击“确定”后,当我测试连接时,会出现以下错误:

com.microsoft.sqlserver.jdbc.SQLServerException: La connessione TCP/IP all'host localhost, porta 1433 non è riuscita. Errore: "Connection refused: connect. Verificare le proprietà di connessione. Assicurarsi che un'istanza di SQL Server sia in esecuzione sull'host e accetti le connessioni TCP/IP alla porta. Verificare inoltre che le connessioni TCP alla porta non siano bloccate da un firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:328)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
如果我从命令行ping sqlexpress是ok(ping sqlexpress) 防火墙已禁用。
tcp/ip连接是从sql server网络管理启用的

当我们需要连接到sql server,如sqlserveer express 2008/2012时,我们需要使用该jar sqljdbc4.jar并为sqlserver方言编写正确的配置,仅此而已:例如配置(配置位置应位于名为hibernate.cfg.xml的资源文件夹上):


com.micro soft.sqlserver.jdbc.SQLServerDriver
登录
通过
jdbc:sqlserver://127.0.0.1:1433;databaseName=传感器
org.hibernate.dialogue.SQL服务器方言
<?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.micro soft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">login</property>
<property name="hibernate.connection.username">pass</property>
<property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:1433;databaseName=sensors</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQL ServerDialect</property>
</session-factory>
</hibernate-configuration>