de.bezier.data.sql
Class SQL

java.lang.Object
  extended by de.bezier.data.sql.SQL
Direct Known Subclasses:
MySQL, PostgreSQL, SQLite

public class SQL
extends java.lang.Object

SQL library for Processing 1.0 see:

Since:
004
Author:
Florian Jenett - mail@florianjenett.de created: 07.05.2005 - 12:46 Uhr modified: fjenett 20070801

Field Summary
 java.sql.Connection connection
           
 java.lang.String database
           
 java.lang.String driver
           
 java.lang.String previousQuery
           
 java.sql.ResultSet result
           
 java.lang.String server
           
 java.sql.Statement statement
           
 java.lang.String type
           
 java.lang.String url
           
 java.lang.String user
           
 
Constructor Summary
SQL()
          Do not use this contructor.
SQL(processing.core.PApplet _pa, java.lang.String _db)
          You should not directly use the SQL.class instead use the classes for your database type.
SQL(processing.core.PApplet _pa, java.lang.String _serv, java.lang.String _db, java.lang.String _u, java.lang.String _p)
          You should not directly use the SQL.class instead use the classes for your database type.
 
Method Summary
 void close()
          Close the database connection
 boolean connect()
          Open the database connection with the parameters given in the contructor.
 void dispose()
          Callback function for PApplet.registerDispose()
 void execute(java.lang.String _sql)
          Execute a SQL command on the open database connection.
 java.math.BigDecimal getBigDecimal(int _column)
           
 java.math.BigDecimal getBigDecimal(java.lang.String _field)
          Read a java.math.BigDecimal value from the specified field.
 boolean getBoolean(int _column)
           
 boolean getBoolean(java.lang.String _field)
          Read a boolean value from the specified field.
 java.sql.Date getDate(int _column)
           
 java.sql.Date getDate(java.lang.String _field)
          Read a java.sql.Date value from the specified field.
 double getDouble(int _column)
           
 double getDouble(java.lang.String _field)
          Read a double value from the specified field.
 float getFloat(int _column)
           
 float getFloat(java.lang.String _field)
          Read a float value from the specified field.
 int getInt(int _column)
           
 int getInt(java.lang.String _field)
          Read an integer value from the specified field.
 long getLong(int _column)
           
 long getLong(java.lang.String _field)
          Read a long value from the specified field.
 java.lang.Object getObject(int _column)
           
 java.lang.Object getObject(java.lang.String _field)
          Read a value from the specified field to hav it returned as an object.
 java.lang.String getString(int _column)
           
 java.lang.String getString(java.lang.String _field)
          Read a String value from the specified field.
 java.sql.Time getTime(int _column)
           
 java.sql.Time getTime(java.lang.String _field)
          Read a java.sql.Time value from the specified field.
 java.sql.Timestamp getTimestamp(int _column)
           
 java.sql.Timestamp getTimestamp(java.lang.String _field)
          Read a java.sql.Timestamp value from the specified field.
 boolean next()
          Check if more results (rows) are available.
 void query(java.lang.String _sql)
          Issue a query on the open database connection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

public java.lang.String server

database

public java.lang.String database

url

public java.lang.String url

user

public java.lang.String user

driver

public java.lang.String driver

type

public java.lang.String type

connection

public java.sql.Connection connection

previousQuery

public java.lang.String previousQuery

statement

public java.sql.Statement statement

result

public java.sql.ResultSet result
Constructor Detail

SQL

public SQL()
Do not use this contructor.


SQL

public SQL(processing.core.PApplet _pa,
           java.lang.String _db)
You should not directly use the SQL.class instead use the classes for your database type.


SQL

public SQL(processing.core.PApplet _pa,
           java.lang.String _serv,
           java.lang.String _db,
           java.lang.String _u,
           java.lang.String _p)
You should not directly use the SQL.class instead use the classes for your database type.

Method Detail

connect

public boolean connect()
Open the database connection with the parameters given in the contructor.


execute

public void execute(java.lang.String _sql)
Execute a SQL command on the open database connection.

Parameters:
_sql - The SQL command to execute

query

public void query(java.lang.String _sql)
Issue a query on the open database connection

Parameters:
_sql - SQL command to execute for the query

next

public boolean next()
Check if more results (rows) are available. This needs to be called before any results can be retrieved.

Returns:
boolean true if more results are available, false otherwise

getInt

public int getInt(java.lang.String _field)
Read an integer value from the specified field. Represents an INT / INTEGER type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
int Value of the field or 0

getInt

public int getInt(int _column)

getLong

public long getLong(java.lang.String _field)
Read a long value from the specified field. Represents a BIGINT type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
long Value of the field or 0

getLong

public long getLong(int _column)

getFloat

public float getFloat(java.lang.String _field)
Read a float value from the specified field. Represents a REAL type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
float Value of the field or 0

getFloat

public float getFloat(int _column)

getDouble

public double getDouble(java.lang.String _field)
Read a double value from the specified field. Represents FLOAT and DOUBLE types: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
double Value of the field or 0

getDouble

public double getDouble(int _column)

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String _field)
Read a java.math.BigDecimal value from the specified field. Represents DECIMAL and NUMERIC types: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
java.math.BigDecimal Value of the field or null

getBigDecimal

public java.math.BigDecimal getBigDecimal(int _column)

getBoolean

public boolean getBoolean(java.lang.String _field)
Read a boolean value from the specified field. Represents BIT type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
boolean Value of the field or 0

getBoolean

public boolean getBoolean(int _column)

getString

public java.lang.String getString(java.lang.String _field)
Read a String value from the specified field. Represents VARCHAR and CHAR types: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
String Value of the field or null

getString

public java.lang.String getString(int _column)

getDate

public java.sql.Date getDate(java.lang.String _field)
Read a java.sql.Date value from the specified field. Represents DATE type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
java.sql.Date Value of the field or null

getDate

public java.sql.Date getDate(int _column)

getTime

public java.sql.Time getTime(java.lang.String _field)
Read a java.sql.Time value from the specified field. Represents TIME type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
java.sql.Time Value of the field or null

getTime

public java.sql.Time getTime(int _column)

getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String _field)
Read a java.sql.Timestamp value from the specified field. Represents TIMESTAMP type: http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html "8.9.6 Conversions by ResultSet.getXXX Methods"

Parameters:
_field - The name of the field
Returns:
java.sql.Timestamp Value of the field or null

getTimestamp

public java.sql.Timestamp getTimestamp(int _column)

getObject

public java.lang.Object getObject(java.lang.String _field)
Read a value from the specified field to hav it returned as an object.

Parameters:
_field - The name of the field
Returns:
Object Value of the field or null

getObject

public java.lang.Object getObject(int _column)

close

public void close()
Close the database connection


dispose

public void dispose()
Callback function for PApplet.registerDispose()



processing library SQLibrary by Florian Jenett. (c) 2005 - 2009