src/de/bezier/data/sql/SQL.java
public boolean connect()
	{
		if ( driver == null || driver.equals("") ||
			 type == null || type.equals("") )
		{
			System.out.println( "SQL.connect(): You have to set a driver and type first." );
			return false;
		}

		// TODO: need to add mechanisms for different connection types and parameters, see:
		// http://jdbc.postgresql.org/documentation/83/connect.html

		try
		{
			Class.forName(driver);
			connection = java.sql.DriverManager.getConnection(url, user, pass);

		}
		catch (ClassNotFoundException e)
		{
			System.out.println( "SQL.connect(): Could not find the database driver ( "+driver+" ).\r" );
			if (DEBUG) e.printStackTrace();
			return false;

		}
		catch (java.sql.SQLException e)
		{
			System.out.println( "SQL.connect(): Could not connect to the database ( "+url+" ).\r" );
			if (DEBUG) e.printStackTrace();
			return false;

		}

		getTableNames();

		try {
			Driver jdbcDriver = java.sql.DriverManager.getDriver( url );
			if ( jdbcDriver != null ) {
				driverMinorVersion = jdbcDriver.getMinorVersion();
				driverMajorVersion = jdbcDriver.getMajorVersion();

				if ( DEBUG ) System.out.println( "Using driver " + getDriverVersion() );
			}
		} catch ( SQLException sqle ) {
			sqle.printStackTrace();
		}

		return true;
	}
/**
	 *	Open the database connection with the parameters given in the contructor.
	 */
Open the database connection with the parameters given in the contructor.
Open the database connection with the parameters given in the contructor .
public boolean connect()
	{
		if ( driver == null || driver.equals("") ||
			 type == null || type.equals("") )
		{
			System.out.println( "SQL.connect(): You have to set a driver and type first." );
			return false;
		}
		try
		{
			Class.forName(driver);
			connection = java.sql.DriverManager.getConnection(url, user, pass);
		}
		catch (ClassNotFoundException e)
		{
			System.out.println( "SQL.connect(): Could not find the database driver ( "+driver+" ).\r" );
			if (DEBUG) e.printStackTrace();
			return false;
		}
		catch (java.sql.SQLException e)
		{
			System.out.println( "SQL.connect(): Could not connect to the database ( "+url+" ).\r" );
			if (DEBUG) e.printStackTrace();
			return false;
		}
		getTableNames();
		try {
			Driver jdbcDriver = java.sql.DriverManager.getDriver( url );
			if ( jdbcDriver != null ) {
				driverMinorVersion = jdbcDriver.getMinorVersion();
				driverMajorVersion = jdbcDriver.getMajorVersion();
				if ( DEBUG ) System.out.println( "Using driver " + getDriverVersion() );
			}
		} catch ( SQLException sqle ) {
			sqle.printStackTrace();
		}
		return true;
	}
public boolean connect ( ) { if ( driver == null || driver . equals ( "" ) || type == null || type . equals ( "" ) ) { System . out . println ( "SQL.connect(): You have to set a driver and type first." ) ; return false ; } try { Class . forName ( driver ) ; connection = java . sql . DriverManager . getConnection ( url , user , pass ) ; } catch ( ClassNotFoundException e ) { System . out . println ( "SQL.connect(): Could not find the database driver ( " + driver + " ).\r" ) ; if ( DEBUG ) e . printStackTrace ( ) ; return false ; } catch ( java . sql . SQLException e ) { System . out . println ( "SQL.connect(): Could not connect to the database ( " + url + " ).\r" ) ; if ( DEBUG ) e . printStackTrace ( ) ; return false ; } getTableNames ( ) ; try { Driver jdbcDriver = java . sql . DriverManager . getDriver ( url ) ; if ( jdbcDriver != null ) { driverMinorVersion = jdbcDriver . getMinorVersion ( ) ; driverMajorVersion = jdbcDriver . getMajorVersion ( ) ; if ( DEBUG ) System . out . println ( "Using driver " + getDriverVersion ( ) ) ; } } catch ( SQLException sqle ) { sqle . printStackTrace ( ) ; } return true ; }
Open the database connection with the parameters given in the contructor.
Open the database connection with the parameters given in the contructor .
// TODO: need to add mechanisms for different connection types and parameters, see: // http://jdbc.postgresql.org/documentation/83/connect.html