jdbc连接数据库,record无测试结果返回
Posted by ypspace on
URL: http://ngrinder.373.s1.nabble.com/jdbc-record-tp871.html
参照样例程序编写了使用jdbc连接sybase数据库的测试脚本,脚本调试通过,已验证可以连到数据库中查询。
但,问题是统计结果中没有定义test的结果数据,不知道原因出在哪里?
例外,本人又使用mysql jdbc连接mysql进行测试,问题依旧?
以下是测试脚本:
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from java.sql import DriverManager
from com.sybase.jdbc3.jdbc import SybDriver
debug = True
test1 = Test(1, "testASE")
# Load the Sybase JDBC driver.
DriverManager.registerDriver(SybDriver())
def getConnection():
return DriverManager.getConnection("jdbc:sybase:Tds:192.168.1.100:5000/user", "sa", "password")
def ensureClosed(object):
try: object.close()
except: pass
class TestRunner:
def __call__(self):
connection = None
statement = None
try:
connection = getConnection()
statement = connection.createStatement()
test1.record(statement)
sql = "select * from user..test"
if debug: print sql
rs = statement.executeQuery(sql)
if debug: print type(rs)
while rs.next():
print rs.getString("network_address")
if debug: print "Database OK"
finally:
ensureClosed(statement)
ensureClosed(connection)
以下是日志中结果显示:
Tests Errors Mean Test Test Time TPS
Time (ms) Standard
Deviation
(ms)
Totals 0 0 - 0.00 0.00