使用sqljdbc4.jar
刚开始配置了hibernate.cfg.xml属性
[color=green]<property name="hibernate.connection.url">
jdbc:sqlserver://localhost:1433;DatabaseName=hibernate
</property>
<property name="hibernate.connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</property>[/color]运行报出如下错误:
com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“connect timed out。请验证连接属性,并检查 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。”
之后通过
在命令行 输入 netstat -an查看有没有1433端口,发现没有
修改配置如下:
[color=red]<property name="hibernate.connection.url">
jdbc:sqlserver://localhost:1434;DatabaseName=hibernate
</property>[/color]
运行成功
查询分析其中查看sql server 2008端口:
[color=blue]exec sys.sp_readerrorlog 0, 1, 'listening'[/color]
刚开始配置了hibernate.cfg.xml属性
[color=green]<property name="hibernate.connection.url">
jdbc:sqlserver://localhost:1433;DatabaseName=hibernate
</property>
<property name="hibernate.connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</property>[/color]运行报出如下错误:
com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“connect timed out。请验证连接属性,并检查 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。”
之后通过
在命令行 输入 netstat -an查看有没有1433端口,发现没有
修改配置如下:
[color=red]<property name="hibernate.connection.url">
jdbc:sqlserver://localhost:1434;DatabaseName=hibernate
</property>[/color]
运行成功
查询分析其中查看sql server 2008端口:
[color=blue]exec sys.sp_readerrorlog 0, 1, 'listening'[/color]