I am running my java web application on glassfish server v4.1 in netbeans v8.0.2, using sqljdbc42 and this connection code-
Connection connection;
String url = "jdbc:sqlserver://localhost:1433;databaseName=Lista;integratedSecurity=true";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection = DriverManager.getConnection(url);
When i open my ide and run my project for the first time the glassfish server starts automatically since my project's server is glassfish, and i can perform any crud operation with my Ms-Sql server2012.
But the problem starts when i make changes in any file keeping the server on and run the project again and try to perform any crud operation i get this following error-
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not
configured for integrated authentication
But if i stop the server before changing any file and start after changing and run the project then it works without any error.
Stopping and re-starting the server again and again taking so many times from my total project time! Any help or suggestion will be appreciated.
Thank You.
I solved my problem!
The error (described in my question above) i was getting because the glassfish server had not any access on sqljdbc42.jar file. so i have placed the sqljdbc42.jar file into my glassfish server in this location-
glassfish-4.1\glassfish\domains\domain1\lib.
And it's now working perfectly.
Thank you everyone!
Related
I have an application that connects to a Derby database using the Derby Network Server that has been started as a standalone process outside of the Netbeans IDE.
When I run my application within the IDE (I don't start the Network Server from the Services tab as it is already running) the following is observed:-
The application connects successfully to the server.
Subsequent database accesses fail with error Internal Exception: java.sql.SQLNonTransientConnectionException: The connection was refused because the database MyAppDB was not found.
Error Code: 40000
The persistence.xml in Netbeans shows the following for the JDBC connection:-
jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB
[david on TEST]
However the xml source in Netbeans shows the following:-
jdbc:derby://localhost:1527/MyAppDB
I can fix this problem by changing the persistence.xml source (in Netbeans) to show the following for JDBC connection:-
jdbc:derby://localhost:1527//Users/David/Desktop/DerbyDatabases/MyAppDB
Everything now works and the application runs fine :-)
HOWEVER!!!
As soon as I tell Netbeans to do a Clean and Build Project, it reverts the JDBC connection back to:-
jdbc:derby://localhost:1527/MyAppDB
On running the Application it can no longer access the Db with the same error as above.
Note that none of these problems occur if I run the Network Server from with Netbeans by opening the connection via the Services tab. This is no good for me as I want to deploy the application.
Do any of you guys know what is going on here? - I'm sure it's a simple mistake on my part.
Thank you.
This problem was eventually solved by deleting the persistence unit (using NetBeans) and re-creating it with the same name but with the JDBC connection containing the correct path. Is this a NetBeans problem?
I am trying to run a simple java web app that connects to a back end DB2 database(IBM dashdb) to get retrieve some data.
I am getting a weird error message when I try to run this application on a ubuntu hosted tomcat 8.5.
I managed to get this application running on a tomcat v8 hosted on Windows.
The actual error message is:
No suitable driver found for jdbc:db2://yp-dashdb......
I don't really understand why this is happening because I have the db2jcc4. in my web-inf\lib folder.
I thought it was something wrong with the library so I created a separate Java app to simply connect and retrieve some data from the database. That one works just fine with the same library.
This is the code used to set up the connection (I trimmed out some of the details).
private Connection conn = null;
conn= DriverManager.getConnection("jdbc:db2://yp-dashdb...");
Keep in mind, that this exact same code works in a Standard Java app so the connection details work and there's no typo in the connection info.
Is there something obvious that I'm overlooking here?
After spending some time trying to figure this one out I find out the problem. My drivers were not being registered by DriverManager. The quick fix I found for this was to manually register it before trying to load the driver.
DriverManager.registerDriver(new com.ibm.db2.jcc.DB2Driver());
This has solved my issue. The way I found out about this was to print out all the registered drivers and print them out. Not the most elegant solution but it helped me find out what I'm missing.
/*
System.out.println("checking for drivers");
Enumeration<Driver> myDrivers = DriverManager.getDrivers();
System.out.println(myDrivers.hasMoreElements());
while(myDrivers.hasMoreElements()){
System.out.println(myDrivers.nextElement().toString());
}
*/
WEB-INF/lib is in your application. It might be so that tomcat needs this driver before your app is loaded? Try putting it into the tomcat's lib folder and restarting...
Here is another question on the same topic: Why must the JDBC driver be put in TOMCAT_HOME/lib folder?
I followed this tutorial to build a spring websocket application. I've kept each file as it is but I'm neither using maven nor gradle. I run the index.html file on the tomcat server. When I click connect I get:
Opening Web Socket... GET http://localhost:8080/hello/info 404 (Not
Found) Whoops! Lost connection to undefined
in my Chrome's Developer window.
Why is this happening?
link may help. here I have given whole example.
for this you will require stomp.js, sockjs on your client side
and spring-websocket & spring-messaging 4.2.6.RELEASE jar in your server side,
I use the following code:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// Make connection
Connection connection = DriverManager.getConnection("jdbc:sqlserver://sqltest.ABC.com:1433;databaseName=test5;integratedSecurity=true");
If I run my project in Eclipse under Tomcat server goes well. But if I export my project as a WAR file en start the tomcat appache I get the error message " Login failed for user 'DomainName / ServerName'.
I do not know how he got these login data!
You use integrated authentication with your database. So you'll need the authentication dll provided by microsoft in your java.library.path. If you run tomcat as a service, your service has to run as a user with access privileges on your db as well.
I have tried to install Java EE 7 with updatetool to be able to run Java EE Tutorial examples.
But the installation of updatetool fails. I have tried to start updatetool installation from the command line on my elementary os, then I saw the error when installing updatetool.
Here is an image: http://oi58.tinypic.com/x6iumx.jpg
Error text example 1:
Input/output error: Connection failed for URL http://pkg.oracle.com/javaeesdk/7/native/release/manifest/0/updatetool#2.3.5%2C0-56.2852%3A20111207T211721Z: 503: Service Temporarily Unavailable
Could not download application packages. This could be because:
- a proxy server is needed to access the internet. Please ensure that
the system proxy server settings are correct, or set the 'http_proxy'
environment variable to the full URL of the proxy server.
- the package server or network connection is slow.
If you are getting time out errors you can try setting the
PKG_CLIENT_CONNECT_TIMEOUT and PKG_CLIENT_READ_TIMEOUT
environment variables and try again. For example to increase
the timeouts to 300 seconds set them to 300
- the package server is down or otherwise inaccessible or it is
generating invalid data. Please contact the provider of the package
server.
Error text example 2:
File 138/564 Input/output error: Connection failed for URL http: //pkg.oracle.com/javaeesdk/7/native/release/file/0/217e83782a91f09fa7f35122412cd155263b107f: 502: Proxy Error
Could not download application packages. This could be because:
- a proxy server is needed to access the internet. Please ensure that
the system proxy server settings are correct, or set the 'http_proxy'
environment variable to the full URL of the proxy server.
- the package server or network connection is slow.
If you are getting time out errors you can try setting the
PKG_CLIENT_CONNECT_TIMEOUT and PKG_CLIENT_READ_TIMEOUT
environment variables and try again. For example to increase
the timeouts to 300 seconds set them to 300
- the package server is down or otherwise inaccessible or it is
generating invalid data. Please contact the provider of the package
server.
I don't use any proxy server. Help please!
I had the same - it's because their site is so unbelievably slow.
The output you showed tells you what to do, increase the timeout.
But sometimes it just needs to be run again, which worked in my case.
You can download the tutorial from Oracle Java EE 7 SDK download page.
Just download the latest Java EE 7 SDK, and unzip. The tutorial is inside the glassfish4/docs folder.
I have managed to install updatetool finally, after 3 days.
My advice for everyone who has the same problem:
Try installation several times in the morning, afternoon, evening and at night. And maybe once you will have successful attempt :)
The problem was not on my side.