How to make apache2 authenticate against MS SQL 2000 Server - Page 2
5. Tools and actual implementationLooking 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. 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 SQLIt took not that much gogling to find some samples and glue together the java ‘program’ that initially looked like that: import java.sql.*;
import java.io.*;
public class testConnection
{
public static void main(String[] args)
{
String userName;
String userPass;
userName = args[0];
userPass = args[1];
DB db = new DB();
db.dbConnect(
"jdbc:jtds:sqlserver://xxx.xxx.xxx.xxx:1433/test",userName,userPass);
}
}
class DB
{
public DB() {}
public void dbConnect(String db_connect_string,
String db_userid, String db_password)
{
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);
System.out.println("connected");
}
catch (Exception e)
{
//e.printStackTrace();
System.out.println("failed");
}
}
};
I've had already Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2) on
that machine.
wget http://belnet.dl.sourceforge.net/sourceforge/jtds/jtds-1.2-dist.zip So now it’s possible to compile the program: javac testConnection.java and run it java testConnection myUsername myPass After that I looked out what can be done from apache's side.
|

![Creative Commons Attribution License [Creative Commons Attribution License]](http://creativecommons.org/images/public/somerights20.gif)


Recent comments
21 hours 39 min ago
1 day 2 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 14 hours ago
1 day 14 hours ago
1 day 17 hours ago
2 days 19 min ago