cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to establish connection with SQLServer from Java Application

Former Member
0 Kudos

Dear All,

I am facing the issue of establishing connection with SQL Server from Java project developed in NWDS. I am writing a jaas plug-in, as a part of that I am writing a login module to authenticate a web application through jaas, and I got need of fetching some data from SQL Server which is located in remote host. I am getting error in the line of code

<b>Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver)</b>

I also added the 3 jar files (msbase.jar,mssqlserver.jar,and msutil.jar) to my login module project and copied the same files at C:\usr\sap\J2E\JC01\j2ee\cluster\server0\bin\ext\MSSQL.

My MI Landscape is j2ee stack + abap stack +WAS 6.40 with MAXDb as a database.

Could anyone please let me know the solution if you are aware of it.

Thanks and Regards,

Kishore.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I solved this issue by using the following code snippet.

Connection con;

Statement stmt;

DataSource ds;

Context ctx;

ctx = new InitialContext();

if(ctx == null) throw new Exception("Boom - No Context");

ds = (DataSource)ctx.lookup("jdbc/SQLDB");

con = ds.getConnection();

Former Member
0 Kudos

hi kishore,

i assume that you have your enclosing quotations...

and what error/exception is being thrown?

if it is class not found, better check your classpath.

regards

jo