Package de.suse.lib.sqlmap.drivers
Class GenericDriver
- java.lang.Object
-
- de.suse.lib.sqlmap.drivers.GenericDriver
-
- All Implemented Interfaces:
DBConnectionDriver
- Direct Known Subclasses:
ApacheDerbyEmbeddedDriver,H2EmbeddedDriver,H2EmbeddedServerDriver,PgSQLDriver
public abstract class GenericDriver extends java.lang.Object implements DBConnectionDriver
Base driver operator.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionCallbackcallbackprotected java.sql.Connectionconnection
-
Constructor Summary
Constructors Constructor Description GenericDriver(java.lang.String url)Create a connection from an URL.GenericDriver(java.sql.Connection conn)Create connection directly from already opened connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()GenericDriverconnect(java.lang.String user, java.lang.String password)Connect to the database.java.sql.ConnectiongetConnection()protected java.lang.StringgetDatabase()protected java.lang.StringgetHost()protected java.lang.StringgetPort()protected java.lang.StringgetUrl()booleanisConnected()Check if driver is connected at the moment.protected voidparseURL()Parse URL for connect.voidsetConnectionCallback(ConnectionCallback callback)protected voidsetDatabase(java.lang.String database)protected voidsetHost(java.lang.String host)protected voidsetPort(java.lang.String port)
-
-
-
Field Detail
-
connection
protected java.sql.Connection connection
-
callback
protected ConnectionCallback callback
-
-
Constructor Detail
-
GenericDriver
public GenericDriver(java.sql.Connection conn)
Create connection directly from already opened connection.- Parameters:
conn-
-
GenericDriver
public GenericDriver(java.lang.String url) throws java.net.URISyntaxException, java.sql.SQLException, java.lang.ExceptionCreate a connection from an URL.- Parameters:
url-- Throws:
java.net.URISyntaxExceptionjava.sql.SQLExceptionjava.lang.Exception
-
-
Method Detail
-
parseURL
protected void parseURL() throws java.sql.SQLExceptionParse URL for connect.- Throws:
java.sql.SQLException
-
connect
public GenericDriver connect(java.lang.String user, java.lang.String password) throws java.lang.Exception
Connect to the database.- Specified by:
connectin interfaceDBConnectionDriver- Returns:
- Throws:
java.lang.Exception
-
isConnected
public boolean isConnected()
Check if driver is connected at the moment.- Specified by:
isConnectedin interfaceDBConnectionDriver- Returns:
-
getDatabase
protected java.lang.String getDatabase()
-
setDatabase
protected void setDatabase(java.lang.String database)
-
getHost
protected java.lang.String getHost()
-
setHost
protected void setHost(java.lang.String host)
-
getPort
protected java.lang.String getPort()
-
setPort
protected void setPort(java.lang.String port)
-
getUrl
protected java.lang.String getUrl()
-
close
public void close()
- Specified by:
closein interfaceDBConnectionDriver
-
getConnection
public java.sql.Connection getConnection()
- Specified by:
getConnectionin interfaceDBConnectionDriver
-
setConnectionCallback
public void setConnectionCallback(ConnectionCallback callback)
- Specified by:
setConnectionCallbackin interfaceDBConnectionDriver
-
-