MSSQL JDBC on unix - java

I am trying to integrate a web tool we have with a sql server database using Integrated Security. I have been looking around trying to find a unix version of the sqljdbc4.jar however I cannot seem to find one with .so files only .dll's.
Does anyone know where I can get a version with the .so files required or another way to use integrated security?
Currently my application is failing to connect with
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication
and I can see
WARNING: Failed to load the sqljdbc_auth.dll
earlier in the logs.
Using version 2.5 of mssqljdbc.

According to these docs, beginning with MSSQL JDBC Driver 4.0, you should be able to specify authenticationScheme=JavaKerberos to use the pure Java Kerberos implementation that doesn't need sqljdbc_auth.dll.
Note, I haven't tried this.

I know its late but for anyone searching this, try the following:
put the sqljdbc_auth.dll in your resource folder then add the following code
ClassLoader classLoader = TestDBConnection.class.getClassLoader();
File file = new File(classLoader.getResource("sqljdbc_auth.dll").getFile());
System.setProperty("java.library.path", file.getParent());

Related

Add dll to jee maven project [duplicate]

This question already has answers here:
Can I connect to SQL Server using Windows Authentication from Java EE webapp?
(5 answers)
Closed 4 years ago.
I am working in a jee maven project that needs to make a JDBC connection to SqlServer, using windows authentication.
To achieve that, I need to have the "sqljdbc_auth.dll" in my java.library.path .
I tried multiple solutions, none of them worked:
maven_surefire_plugin to modify the property path.
System.setProperty("java.library.path", "..."): this changed the property, but the connection didn't succeed telling me that the driver isn't configured for integratedSecurity connection.
Add the dll to a lib folder in Web_Inf & set the "Native Library_Path" of the maven dependency sqljdbc.
Add the dll to the bin folder in the "wildfly" server: gave me an exception: Exception Access Violation (fatal)
I appreciate any help, thank's in advance.
Adding .dll (which is windows-specific library) to JEE application (deployed on application server, usually running on linux platform) sound like a bad idea.
In your case, I believe that solution is much simpler: try to add integratedSecurity=true to your JDBC string, so it would like like this:
String url ="jdbc:sqlserver://localhost\sqlexpress;databaseName=myDatabase;integratedSecurity=true";
If this won't help, maybe consider using jTDS instead of regular driver from Microsoft - from my experience, it works much better.
Try adding below to your JDBC string:
Integrated Security=SSPI
The SSPI allows an application to use any of the available security packages on a system without changing the interface to use security services

Wildfly 10 classloader hell (hibernate doesn't see Postgres Driver installed as module)

I use wildfly Entity Manager for my application, but besides that I need to establish jdbc connection in runtime for other purposes, so I receiving settings from service, in runtime, during application start and establish this connection.
I tried to use sql2o and it works just fine, but then I tried hibernate (I'm creating it programatically), and it didn't work. I took a look on internals and figured out why it doesn't work.
When library calls DriverManager.getConnection() it checks callers ClassLoader. And when sql2o was loaded with an application just like Postgres Driver, the hibernate is not, and it fails.
creating of client sql2o that works just fine
creating hibernate programatically and it fails
Then I was trying to use PostgresDriver installed as Wildfly module and as deployment both ways didn't work.
Furthermore I tried to extract hibernate from wildfly with jboss-deployment-structure.xml, and use bundled from my application. Again it doesn't work.
Every time I'm getting
Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgresql...
I found among registered drivers PostgresDriver loaded with Wildfly's
with classloader id "org.postgres:main", when caller (hibernate's) ClassLoader
has id = "org.hibernate:main". So it's wildfly's modules, but why don't they see each other???
The problem:
I use ear packaging with 2 subdeployments (jar + war), how can I solve this problem, and make wildfly's hibernate see installed as wildfly module Postgres Driver?

Birt: how to deploy a report in production?

I have just prepared a report with bird using eclipse plugin. It works.
Now I have deployed a birt 4.4 viwer on a Tomcat7. It works.
Now I put my report.rptdesign file insider birt folder under webapps in tomcat.
It does not work.
Obviously because:
the jdbc driver is encoded in report with full path that is obviously different from eclipse to tomcat;
birt needs a "org.eclipse.datatools_workspacepath" configured in tomcat (why????)
even if I configure above variable it complains about missing:
java.lang.NoClassDefFoundError: org/eclipse/datatools/enablement/ibm/util/ClientUtil
Yes I have used standard jdbc source (not "for query builder" one).
I would like to ask stack overflow why is so bloody complicated (and not documented) putting in production a simple report that uses a mysql jdbc jar.
Can you help me?
Thanks,
Mario
Well I don't understand all the question but I use birt with glassfish and jboss, you need to configure a JDBC in your server (I suppose you already have done that), then you have to change your Datasources erase all and use a JNDI URL with the name of your JDBC for example, if you create a datasource JDBC/test this is the JNDI url.
For the workspacepath I think this can be solved changing something in the birt war, go to META-INF and open the web.xml, then change this properties for another folders that have sufficient access permissions:
<param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
<param-name>BIRT_VIEWER_DOCUMENT_FOLDER</param-name>
<param-name>BIRT_VIEWER_IMAGE_DIR</param-name>
<param-name>BIRT_VIEWER_LOG_DIR</param-name>

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.

how to embed javadb or hsqldb into java application with hibernate using netbeans?

I successfuly embedded javadb in my application using the classpath ,but here's the problem : I want hibernate to be able to work with the database,but I always get an error in netbeans sayng "enable to establish connection ".
AnyHelp please ?
The URL for a local HSQLDB database is jdbc:hsqldb:file:file_path_name The file_path_name is usually an absolute path with a name at the end. The database engine will then create a few files with the given name, but predefined extensions. An example of this is: jdbc:hsqldb:file:/mydata/mydb which will produce mydb.properties , mydb.script and a couple other files in the /mydata directory.

Categories

Resources