Connect to SQL Server from UNIX

If you are looking for how to connect to SQL Server from UNIX here are few simple steps to configure them

1) First Download n install the POD
2) Then you need to run this JDBC driver as init 3 service. The script is at /etc/rc3.d/S77spmf
Code of S77spmf
# Start/stop processes required for SPMF

case “$1” in
echo “Usage: $0 { start | stop }”
exit 1
exit 0
3) Copy these jar & properties files into a separate directory and start the JDBC service as given below in the script
/usr/bin/java -Xms64m -Xmx512m -Djdbc.drivers=$DRIVERS -Ddbd.port=9001 com.vizdom.dbd.jdbc.Server &
echo $JDBC_PID > /apps/iw-home/local/bin/spmf/db/
echo “Killing: `cat /apps/iw-home/local/bin/spmf/db/`”
kill -9 `cat /apps/iw-home/local/bin/spmf/db/`
4) Now connect to the JDBC port 9001 instead of the SQL Server port in the code
use DBI;
use DBD::JDBC;
my $dbh = DBI->connect( “dbi:JDBC:hostname=$host;port=9001;url=jdbc:sqlserver://tucgpsqlnp:1445″,”userid”,”password” ) or die print $DBI::errstr;
my $sql = “select DepartmentID from Department where DepartmentName like ‘$dept%'”;
$sth = $dbh->prepare($sql);
That’t it. Enjoy


One thought on “Connect to SQL Server from UNIX

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s