com.partnersoft.sql
Class SqlDatabase

java.lang.Object
  extended by com.partnersoft.sql.SqlDatabase
All Implemented Interfaces:
Coggable
Direct Known Subclasses:
DatabaseConnectionConfig

public class SqlDatabase
extends java.lang.Object
implements Coggable

Description and configuration for a database connection - driver, URL, user, password, etc. Mostly designed to simplify the task of creating those horrible JDBC URLs.

There are three major varieties of configuration. For file-based databases like Microsoft Access and HSQLDB, use this format:

 config = new SqlDatabase();
 config.setType("Access");
 config.setPath("c:/path/to/mydata.mdb");
 
For server-based databases like Microsoft SQL Server and MySQL, use this format:
 config = new SqlDatabase();
 config.setType("MySQL");
 config.setServer("192.168.1.1");
 config.setName("partner");
 config.setUser("paul");
 config.setPassword("secretmagicword");
 
Finally, if it's a nonstandard (for Partner) database, or if you can't get the config to work correctly using individual properties, you can specify just a JDBC driver and JDBC URL. Note that if you do so, it completely overrides and ignores all other settings except for the username and password.
 config = new SqlDatabase();
 config.setType("other");
 config.setDriver("org.bar.foo.jdbc.WeirdDriver");
 config.setJdbcUrl("jdbc:weirdodb://192.168.1.1/something");
 config.setUser("plokta");
 config.setPassword("ultrasecret");
 

Copyright 2000-2008 Partner Software, Inc. All rights reserved.

Version:
$Id: SqlDatabase.java 2328 2010-01-06 15:38:22Z paul $
Author:
Paul Reavis

Constructor Summary
SqlDatabase()
          Create a new DatabaseConnectionConfig.
SqlDatabase(Cog state)
           
 
Method Summary
 java.lang.String getDatabase()
          Database name for extraction (optional).
 java.lang.String getDriver()
          Database JDBC Driver classname.
 java.lang.String getPassword()
          Database password for extraction (optional).
 java.lang.String getPath()
          Database path for extraction (optional).
 java.lang.String getProperties()
          Database properties for extraction (optional).
 java.lang.String getServer()
          Database server for extraction (optional).
 java.lang.String getType()
          Database type for extraction (optional).
 java.lang.String getUrl()
          Database JDBC URL.
 java.lang.String getUser()
          Database user for extraction (optional).
 SqlConnection openConnection()
          Creates and opens an SqlConnection for this database.
 void setDatabase(java.lang.String newDatabaseName)
           
 void setDriver(java.lang.String newDriver)
           
 void setPassword(java.lang.String newDatabasePassword)
           
 void setPath(Path newDatabasePath)
           
 void setPath(java.lang.String newDatabasePath)
           
 void setProperties(java.lang.String newDatabaseProperties)
           
 void setServer(java.lang.String newDatabaseServer)
           
 void setType(java.lang.String newDatabaseType)
           
 void setUrl(java.lang.String newUrl)
           
 void setUser(java.lang.String newDatabaseUser)
           
 Cog toCog()
          Returns the complete internal state of this object in the form of a Cog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlDatabase

public SqlDatabase()
Create a new DatabaseConnectionConfig.


SqlDatabase

public SqlDatabase(Cog state)
Method Detail

toCog

public Cog toCog()
Description copied from interface: Coggable
Returns the complete internal state of this object in the form of a Cog.

Specified by:
toCog in interface Coggable
Returns:
Cog representing the internal state of this object

openConnection

public SqlConnection openConnection()
                             throws java.sql.SQLException
Creates and opens an SqlConnection for this database.

Throws:
java.sql.SQLException

getPassword

public java.lang.String getPassword()
Database password for extraction (optional).


setPassword

public void setPassword(java.lang.String newDatabasePassword)

getUser

public java.lang.String getUser()
Database user for extraction (optional).


setUser

public void setUser(java.lang.String newDatabaseUser)

getServer

public java.lang.String getServer()
Database server for extraction (optional).


setServer

public void setServer(java.lang.String newDatabaseServer)

getType

public java.lang.String getType()
Database type for extraction (optional).


setType

public void setType(java.lang.String newDatabaseType)

getDatabase

public java.lang.String getDatabase()
Database name for extraction (optional).


setDatabase

public void setDatabase(java.lang.String newDatabaseName)

getPath

public java.lang.String getPath()
Database path for extraction (optional).


setPath

public void setPath(java.lang.String newDatabasePath)

setPath

public void setPath(Path newDatabasePath)

getProperties

public java.lang.String getProperties()
Database properties for extraction (optional).


setProperties

public void setProperties(java.lang.String newDatabaseProperties)

getUrl

public java.lang.String getUrl()
Database JDBC URL. You must also set the driver property.


setUrl

public void setUrl(java.lang.String newUrl)

getDriver

public java.lang.String getDriver()
Database JDBC Driver classname. You must also set the url property.


setDriver

public void setDriver(java.lang.String newDriver)