Hibernate: connection.url for SQL Server .MDF File

▼魔方 西西 提交于 2019-12-13 02:28:15

问题


How do I Hibernate connection.url for SQL Server .MDF File? I've tried

prop.setProperty("hibernate.connection.url", "jdbc:sqlserver://c:\\db.mdf");

but don't work :(

Thx!


回答1:


The property hibernate.connection.url takes the JDBC URL that you have to provide which connects to a database. Read more about it in the documentation.

Eg:

hibernate.connection.url = jdbc:postgresql://localhost/mydatabase

MDF file is an internal representation of data in MS SQL Server. You should be connecting to a SQL Server and not the MDF file. I have also found a question confirming that you can not use a MDF file out side the MS SQL Server.



来源:https://stackoverflow.com/questions/8194547/hibernate-connection-url-for-sql-server-mdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!