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
#!/bin/sh
#
# Start/stop processes required for SPMF
#


case “$1” in
‘start’)
/apps/iw-home/local/bin/spmf/db/start_jdbc.sh
;;
‘stop’)
/apps/iw-home/local/bin/spmf/db/stop_jdbc.sh
;;
*)
echo “Usage: $0 { start | stop }”
exit 1
;;
esac
exit 0
3) Copy these jar & properties files into a separate directory and start the JDBC service as given below in the script
sqljdbc.jar
log4j-1.2.15.jar
dbd_jdbc.jar
log4j.properties
/apps/iw-home/local/bin/spmf/db/start_jdbc.sh
#!/bin/sh
CLASSPATH=/apps/iw-home/local/bin/spmf/db/dbd_jdbc.jar:/apps/iw-home/local/bin/spmf/db/log4j-1.2.15.jar:/apps/iw-home/local/bin/spmf/db:/apps/iw-home/loca
l/bin/spmf/db/sqljdbc.jar
export CLASSPATH
DRIVERS=com.microsoft.sqlserver.jdbc.SQLServerDriver
/usr/bin/java -Xms64m -Xmx512m -Djdbc.drivers=$DRIVERS -Ddbd.port=9001 com.vizdom.dbd.jdbc.Server &
JDBC_PID=$!
echo $JDBC_PID > /apps/iw-home/local/bin/spmf/db/jdbc.pid
/apps/iw-home/local/bin/spmf/db/stop_jdbc.sh
echo “Killing: `cat /apps/iw-home/local/bin/spmf/db/jdbc.pid`”
kill -9 `cat /apps/iw-home/local/bin/spmf/db/jdbc.pid`
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);
$sth->execute()
That’t it. Enjoy

Clear ComboBox in DCT

Since FormAPI doens’t have a method to clear the first NULL value in the dropdown, this workaround should work

var cmb = IWDatacapture.getItem(“/combo”);
var cmb_options = cmb.getOptions();
if (cmb_options != null) {
for (var i = 0; i<cmb_options.length; i++) {
cmb_options[i].selected = false;
}
cmb.setOptions(cmb_options);
}