sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #54331
[Question #689061]: sikuli Connectiong to MSSQL
New question #689061 on Sikuli:
https://answers.launchpad.net/sikuli/+question/689061
Dear All,
I need to make a few queries to a MSSQL database in my sikuli program.
I've installed the microsoft "driver" mssql-jdbc-7.0.0.jre8.jar, but am running into the following error:
zxJDBC.DatabaseError: driver [com.microsoft.jdbc.sqlserver.SQLServerDriver] not found.
1. I add CLASSPATH the Environment Variables in WIN 10.
and I restart WIN 10, and I check it.
PS C:\sikuli\2> Get-ChildItem Env:CLASSPATH | fl
Name : CLASSPATH
Value : c:\Microsoft JDBC Driver 7.0 for SQL Server\sqljdbc_7.0\cht\mssql-jdbc-7.0.0.jre8.jar
But I still get the same error.
and when I run my sikuli script:
import java.lang.System as JS
cp = JS.getProperty("java.class.path")
print cp
It show:
C:\sikuli\2\sikulix-2.0.2.jar;c:/jython2.7.1/jython.jar;
Why sikuli can not get the CLASSPATH?
2.I run java in command line with -cp option as:
java -cp "c:\Microsoft JDBC Driver 7.0 for SQL Server\sqljdbc_7.0\cht" -jar c:\sikuli\2\sikulix-2.0.1.jar -r ..\sam\testsql.sikuli\testsql.py
or
java -cp "c:\Microsoft JDBC Driver 7.0 for SQL Server\sqljdbc_7.0\cht\mssql-jdbc-7.0.0.jre8.jar" -jar c:\sikuli\2\sikulix-2.0.1.jar -r ..\sam\testsql.sikuli\testsql.py
But still get the same error,
and my sikuli script:
import java.lang.System as JS
cp = JS.getProperty("java.class.path")
print cp
It still show:
C:\sikuli\2\sikulix-2.0.2.jar;c:/jython2.7.1/jython.jar;
Why sikuli can not get the -cp value?
3.I add the path of my mssql-jdbc to java.class.path in my sikuli program , but it still get the same error:
zxJDBC.DatabaseError: driver [com.microsoft.jdbc.sqlserver.SQLServerDriver] not found.
####my sikuli testsql..sikuli
import java.lang.System as JS
cp = JS.getProperty("java.class.path")
print cp
cp += "c:\jython2.7.1\jython.jar;c:\Microsoft JDBC Driver 7.0 for SQL Server\sqljdbc_7.0\cht\mssql-jdbc-7.0.0.jre8.jar;C:\Users\user\AppData\Roaming\Sikulix\Lib\zxJDBC.jar;"
JS.setProperty("java.class.path", cp)
print JS.getProperty("java.class.path")
from com.ziclix.python.sql import zxJDBC
load("c:\Microsoft JDBC Driver 7.0 for SQL Server\sqljdbc_7.0\cht\mssql-jdbc-7.0.0.jre8.jar")
conn = None
d, u, p, v = "jdbc:sqlserver://UMTP-17-034\MYNB", "sa", "samSQL!@#", "com.microsoft.sqlserver.jdbc.SQLServerDriver"
try:
conn = zxJDBC.connect(d, u, p, v)
cursor = conn.cursor()
cursor.execute("SELECT * FROM dbname.dbo.tablename as a WHERE a.fieldone = 'sometext' and a.fieldtwo = somevalue")
print cursor.fetchone()
print "DB Name: " + conn.dbname
print "DB Version: " + conn.dbversion
print "Driver Name: " + conn.drivername
print "Driver Version: " + conn.driverversion
print "Database URL: " + str(conn.url)
print "Connection info: " + str(conn.__connection__)
print "Is connection closed? -> " + str(conn.closed)
conn.close()
except:
exc_type, exc_val, exc_tb = sys.exc_info()
ErrorText = "***** ERROR IN SCRIPTNAME = " + sys.argv[0] + " *****\n"
#ErrorText += "Date/Time : " + str(datetime.datetime.now()) + "\n"
ErrorText += "Date/Time : " + time.strftime('%m-%d-%y')+ "\n"
ErrorText += "Line Number: " + str(exc_tb.tb_lineno) + "\n"
ErrorText += "Error Type : " + exc_type.__name__ + "\n"
ErrorText += "Error Value: " + exc_val.message + "\n"
ErrorText += "***************************************************************\n\r"
print ErrorText
Has someone has any solution?
Thank you.
Sam Wang
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.