问题
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