a guest Jan 20th, 2017 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- from java.sql import DriverManager
- from net.grinder.script.Grinder import grinder
- from net.grinder.script import Test
- from com.mysql.jdbc import Driver
- test1 = Test(1, "Database insert")
- test2 = Test(2, "Database query")
- #Load the MySQL JDBC driver.
- def getConnection():
- return DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
- "root", "Sasken@123")
- def ensureClosed(object):
- try: object.close()
- except: pass
- class TestRunner:
- def __call__(self):
- connection = None
- insertStatement = None
- queryStatement = None
- print "connection"
- connection = getConnection()
- insertStatement = connection.createStatement()
- print "try connection"
- print "test1 record"
- insertStatement.execute("insert into testing values(%d)"
- print "insert"
- print "test2 record"
- queryStatement.executeQuery("select * from testing")
- print "select"
- except SyntaxError:
- print "can't execute db"
- Thanks Advance.
RAW Paste Data