How to make apache2 authenticate against MS SQL 2000 Server - Page 2

5. Tools and actual implementation

Looking around for sollution it turned out that connecting from Linux to MS SQL is not that straightforward. Ruby, perl, python - all have nice DBI (database interface modules) but when it comes to MS - it's getting painful.
Please correct me if i'm wrong.

I was aware that on the same Linux machine runs jboss application that is web interface to the same MS SQL database. So looking into direction of java seamed most appropriate solution.

5.1. connecting from Java to MS SQL

It took not that much gogling to find some samples and glue together the java ‘program’ that initially looked like that:

import java.sql.*;
public class testConnection
    public static void main(String[] args)
      String userName;
      String userPass;
      userName = args[0];
      userPass = args[1];
    DB db = new DB();
class DB
    public DB() {}
    public void dbConnect(String db_connect_string,
  String db_userid, String db_password)
            Connection conn = DriverManager.getConnection(
    db_connect_string, db_userid, db_password);
        catch (Exception e)

I've had already Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2) on that machine.
So only non out-of-the-box thing was net.sourceforge.jtds.jdbc.Driver part.
This is the driver that needs to be ‘installed’ to access MS SQL form java.
This project is located at . I installed it like that:

cp jtds-1.2.jar /usr/lib/java/jre/lib/ext/

So now it’s possible to compile the program:


and run it

java testConnection myUsername myPass

After that I looked out what can be done from apache's side.

Share this page:

0 Comment(s)

Add comment