简体   繁体   中英

JDBC and Sql Server 2008 Connectivity

I am accessing an SQL server 2008 Database through JDBC4.0. the problem is I can access my DB just when my glassfish server is restarted, it run the code normally but once, if i make any changes into the code i have to restart the glassfish server otherwise it generate the following error.

WARNING: Failed to load the sqljdbc_auth.dll cause : Native Library C:\\Windows\\System32\\sqljdbc_auth.dll already loaded in another classloader

Kindly guide me what should i do to solve this problem i am using Eclipse editor. and my code is

String url = "jdbc:sqlserver://localhost;databaseName=ProductDB; integratedSecurity=true;";
             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
        con = DriverManager.getConnection(url);
        System.out.println("Connected");

If you have a data source correctly defined in GlassFish you should be able to simply re-deploy your application in order to see changes to .java files (you can even use hot deploy although my experience with that has been less than great). XML files shouldn't even need a redeploy.

Update: I see from your edit you are loading the driver etc manually. I suggest you let GlassFish manage the data source and use resource injection to acquire a connection.

Edit: Re-reading your question properly... you don't need the sqljdbc_quth.dll library if you are using sql authentication but it will speeds up authentication with the sql server. I tried it out with one of our products but it didn't make any noticeable difference so I've not bothered since.

If you do any changes in xml or .java file definitely you have to restart.

If you use re loadable resource-bundle to read properties file its ok.

Updated : Just go to Project in top bar than check "Build Automatically". It will stop auto building the project and saves your precious time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM