Failed to Connect to Database in SQL EXPRESS 2010 from Java Application - java

I am having problems trying to connect from a Java application (Netbeans IDE 8.0.2) to a database in SQL EXPRESS 2010. I know that the connection parameters are correct since if I try to make the connection running the application from Netbeans it works fine, but If I try to make the connection running the aplication with the .jar, the try-catch shows me the following error:
Com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId: ad61b2cf-071d-4561-9416-c31f8e918a34
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2400)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:68)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3132)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:704)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:54)
at sqlserver.SqlServer.checkNewConnection(SqlServer.java:67)
at view.Dialogs.configConnection(Dialogs.java:269)
at demosocketserial.DemoSocketSerial.checkConnection(DemoSocketSerial.java:211)
at demosocketserial.DemoSocketSerial.main(DemoSocketSerial.java:41)
Caused by: java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<clinit>(AuthenticationJNI.java:41)
... 15 more
I already copied the sqljdbc_auth.dll file to the Windows System32 folder (that's how I made the connection successful from Netbeans) but I did not get the program to work from the .jar inside the "dist" folder.

Related

Jenkins agent crashed/Terminated Caused by: java.security.AccessControlException:

Nov 02, 2021 9:53:03 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFORMATION: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Nov 02, 2021 9:53:03 AM org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader run
INFORMATION: Waiting for ProtocolStack to start.
Nov 02, 2021 9:53:08 AM hudson.remoting.UserRequest perform
WARNUNG: LinkageError while performing UserRequest:hudson.slaves.SlaveComputer$SlaveInitializer#6cfcc55d
java.lang.ExceptionInInitializerError
at hudson.slaves.SlaveComputer$SlaveInitializer.call(SlaveComputer.java:1042)
at hudson.slaves.SlaveComputer$SlaveInitializer.call(SlaveComputer.java:1033)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:376)
at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:122)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "hudson.util.RingBufferLogHandler.defaultSize" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.sun.javaws.security.JavaWebStartSecurity.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at java.lang.Integer.getInteger(Unknown Source)
at java.lang.Integer.getInteger(Unknown Source)
at hudson.util.RingBufferLogHandler.<clinit>(RingBufferLogHandler.java:39)
... 11 more
I have jenkins agent running on windows 10 , when i start the agent via jnlp file its connect i can see "Connected" but then Terminated the next second , when I went into the Jenkins/remoting/logs i found out this error , any one can please help what is the issue and why its getting terminated after connection
My windows agent have OpenJDK 1.8.0
For Jnlp I am using open web start
Jenkins is of latest version 2.318 on agent and master
My master is of linux
Following steps I already tried
I updated my agent JDK to JDK11 but no success so I just downgrade it , i tried to restart/reboot but nothing can helped
Please any jenkins expert can help me with this
Incase any one in future might search for this here is an answer to that problem
The problem does not lies within the jenkins agent or jenkins master but it is the problem with jnlp launcher as with Open web start
When I tried to connect my agent via cmd running command and passing agent.jar it connects to my master and works fine
so any one in future ever encounter problem like this dont touch or change your jdk setting for master or agent but tried to figure out the security / certificate settings of java web start or Open web start whatever you are using
Thanks
For windows node only
There are some dependecies, keep them at same location (dependecies)
You can create the service manually if you have reference. or follow the below steps:
create service using below command:
sc create "service_name" binpath= "path to jenkins-slave.exe" start=auto
Open RUN, type regedit --> this will take you to registry editor.
on editor find your service:
HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Services -> jenkins_slave (name is same as step 1)
Click on service name and edit Object name (put a user that has access to this machine) -- save
open services.msc and open jenkins_slave properties --> Logon --> enter password for user put in step 4.
start the service -- boom jenkins node is connected :D

No suitable driver found for Hibernate using Jersey

I am doing a program of hibernate with Jersey using mysql.all configuration is correct as I had run the program through main.and got the desired output. but when I call the program as web application and hit the rest URL it gives connection
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at com.util.EmpUtil.selecthql(EmpUtil.java:76) at
com.util.RestController.selectAll(RestController.java:47)
Caused by: java.sql.SQLException: No suitable driver found for
jdbc:mysql://127.0.0.1/test at
java.sql.DriverManager.getConnection(Unknown Source) at
java.sql.DriverManager.getConnection(Unknown Source) at
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
I am getting session object and i have all jars attached.as program is running using main function.Is there any difference between running a program using main and as web application.

Using db2 10.5 exception while trying to connect to db

Hi I am unable to connect to database from cmd, there is a problem in establishing a connection. I am using DB2 10.5 version client. Databse is on 10.5 server (Triend with db on 9.7 version server too).
I get the below excpetion :
com.ibm.db2.jcc.am.SqlException: [jcc][4038][12241][3.69.24] T2LUW exception: SQL1042C An unexpected system error occurred. SQLSTATE=58004
ERRORCODE=-1042, SQLSTATE=58004
at com.ibm.db2.jcc.am.gd.a(Unknown Source)
at com.ibm.db2.jcc.am.gd.a(Unknown Source)
at com.ibm.db2.jcc.am.gd.a(Unknown Source)
at com.ibm.db2.jcc.uw.UWExceptionGenerator.a(Unknown Source)
at com.ibm.db2.jcc.uw.UWExceptionGenerator.a(Unknown Source)
at com.ibm.db2.jcc.uw.UWConnection.a(Unknown Source)
at com.ibm.db2.jcc.uw.f.b(Unknown Source)
at com.ibm.db2.jcc.uw.UWConnection.a(Unknown Source)
at com.ibm.db2.jcc.uw.UWConnection.a(Unknown Source)
at com.ibm.db2.jcc.uw.UWConnection.<init>(Unknown Source)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source)
at com.ibm.db2.jcc.DB2Driver.connect(Unknown Source)
at com.ibm.db2.jcc.DB2Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at DBOperation.setConnection(DBOperation.java:38)
at DBOperation.<init>(DBOperation.java:11)
at VTLoadStandard.main(VTLoadStandard.java:237)
Please help on resolving the issue.
Have a look at the manual entry for this error message.
It may be that your database configuration needs to be upgraded.
Explanation
A system error occurred. Some possible reasons for this error are:
The database manager is not installed correctly or the environment is not set up correctly.
On UNIX-based systems, db2iupdt may need to be run in order to update the DB2 instance to enable acquisition of a new system
configuration or access to function associated with the installation
or removal of certain product options, FixPaks, or modification
levels.
You might get this message if you are not using the correct DB2 Administration Server password.
There is more information about the error at the page I linked above.
You should check the contents of the DB2 diagnostics log file (db2diag.log) on the server side. The JDBC driver itself usually does not raise errors of such type, so there must be something wrong on the server.
For me the following helped: make sure you set the driver type 4.
db2datasource.setDriverType(4);
// put driverType=4; into the jdbc url

error with JSP/ Servlets progam when executing on port 8080:

I have moved my project into my webapps directory under the tomcat 6.0 directory and am running this under the updated url using port 8080.
Has anyone ever seen this error?
**java.lang.UnsatisfiedLinkError: Native Library D:\oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll already loaded in another classloader**
java.lang.ClassLoader.loadLibrary0(Unknown Source)
java.lang.ClassLoader.loadLibrary(Unknown Source)
java.lang.Runtime.loadLibrary0(Unknown Source)
java.lang.System.loadLibrary(Unknown Source)
oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3147)
java.security.AccessController.doPrivileged(Native Method)
oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3143)
oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:221)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:132)
oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:78)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
I am curious to find out what the first line of this stack trace is.
What does this mean?
Please let me know if more information is required from my program.
Thank you in advance.
Sonny
As error saying - you can not load dll lirary from two separate class loaders. Most likely you have two separate Web Applications using connection to Oracle.
Please try to move oracle library jar to Tomcat shared/lib folder, so library will be loaded only once by Tomcat Common Class Loader.
Hello all I solved my own issue. I had to change the path of the oracle database to a jdbc thin client url as opposed to directly connecting to the oracle database.
originally I was using the statement: intfdb.JDBCOCIDRV=jdbc:oracle:oci:#GPSTRKPD.na.jnj.com
to connect which was causing the error.
I change my statement to: jdbc:oracle:thin:#psgtwp0.na.jnj.com:1531:gpstrkpd and it works fine now. Thanks for all of your input.
Sonny

JDBC Connection Exception with MS SQL Server 2008

I am using windows server 2003 on VM vare on which I have my database on MS SQL Server 2008 . Now when I used jdbc driver to connect my java code with database I am getting following exception. Kindly give some solution .
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext([B[I[BI[B[I[ZLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/util/logging/Logger;)I
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext(Native Method)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.GenerateClientContext(AuthenticationJNI.java:80)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at test.jdbcdemo.main(jdbcdemo.java:24)
You have enabled integratedSecurity. This means that the sqljdbc_auth.dll needs to be on the library path of the jvm.
Most likely you do not have this library on your path, it is the wrong version or the wrong variant (x86 <> x64 <> IA64).
An old question but I had this issue today. I don't know the first thing about Java but for me the fix was to copy Microsoft's JDBC driver to Java's ext folder.
sqljdbc41.jar needs to be copied to C:\[path to java installation]\Java\jre7\lib\ext\
Make sure you pick the right version (x86 or x64).
Also for Integrated Security I needed to make a reference to auth when starting my application.
-Djava.library.path=C:\[Path to Microsoft JDBC Driver 4.1 for SQLServer]\sqljdbc_4.1\enu\auth\x86
I had the same exception when starting SpringBatch with an JdbcBatchItemWriter writing to MS SQL Server 2008.
Sqljdbc_auth.dll was on the library path. It turned out that I was running my SpringBatch application in Eclipse with JRE 1.6. I solved this by running it with JRE 1.7 (Eclipse JRE-Tab in Run-Configurations).

Categories