66"""
77
88try :
9- from thirdparty import jaydebeapi
9+ import jaydebeapi
1010 import jpype
1111except ImportError , msg :
1212 pass
1313
1414import logging
1515
16+ from lib .core .common import checkFile
17+ from lib .core .common import readInput
1618from lib .core .data import conf
1719from lib .core .data import logger
1820from lib .core .exception import SqlmapConnectionException
1921from plugins .generic .connector import Connector as GenericConnector
2022
2123class Connector (GenericConnector ):
2224 """
23- Homepage: http://jpype.sourceforge.net/
24- User guide: http://jpype.sourceforge.net/doc/user-guide/userguide.html
25- API: http://code.google.com/p/pymysql/
26- Debian package: <none>
27- License: Apache License V2 .0
25+ Homepage: https://pypi.python.org/pypi/JayDeBeApi/ & http://jpype.sourceforge.net/
26+ User guide: https://pypi.python.org/pypi/JayDeBeApi/#usage & http://jpype.sourceforge.net/doc/user-guide/userguide.html
27+ API: -
28+ Debian package: -
29+ License: LGPL & Apache License 2 .0
2830 """
2931
3032 def __init__ (self ):
@@ -33,20 +35,23 @@ def __init__(self):
3335 def connect (self ):
3436 self .initConnection ()
3537 try :
36- jar = './thirdparty/hsqldb/hsqldb.jar'
37- args = '-Djava.class.path=%s' % jar
38+ msg = "what's the location of 'hsqldb.jar'? "
39+ jar = readInput (msg )
40+ checkFile (jar )
41+ args = "-Djava.class.path=%s" % jar
3842 jvm_path = jpype .getDefaultJVMPath ()
3943 jpype .startJVM (jvm_path , args )
40- except ( Exception ) , msg : #todo fix with specific error
44+ except Exception , msg :
4145 raise SqlmapConnectionException (msg [0 ])
46+
4247 try :
4348 driver = 'org.hsqldb.jdbc.JDBCDriver'
4449 connection_string = 'jdbc:hsqldb:mem:.' #'jdbc:hsqldb:hsql://%s/%s' % (self.hostname, self.db)
4550 self .connector = jaydebeapi .connect (driver ,
4651 connection_string ,
4752 str (self .user ),
4853 str (self .password ))
49- except ( Exception ) , msg : #todo what kind of error is this?!
54+ except Exception , msg :
5055 raise SqlmapConnectionException (msg [0 ])
5156
5257 self .initCursor ()
@@ -55,7 +60,7 @@ def connect(self):
5560 def fetchall (self ):
5661 try :
5762 return self .cursor .fetchall ()
58- except ( Exception ) , msg :
63+ except Exception , msg :
5964 logger .log (logging .WARN if conf .dbmsHandler else logging .DEBUG , "(remote) %s" % msg [1 ])
6065 return None
6166
@@ -65,10 +70,8 @@ def execute(self, query):
6570 try :
6671 self .cursor .execute (query )
6772 retVal = True
68- except (Exception ), msg : #todo fix with specific error
69- logger .log (logging .WARN if conf .dbmsHandler else logging .DEBUG , "(remote) %s" % msg [1 ])
7073 except Exception , msg : #todo fix with specific error
71- raise SqlmapConnectionException ( msg [1 ])
74+ logger . log ( logging . WARN if conf . dbmsHandler else logging . DEBUG , "(remote) %s" % msg [1 ])
7275
7376 self .connector .commit ()
7477
0 commit comments