<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: JDBC code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 19:05:35 GMT</pubDate>
    <description>DZone Snippets: JDBC code</description>
    <item>
      <title>How to produce daily database table dumps in CSV format</title>
      <link>http://snippets.dzone.com/posts/show/4790</link>
      <description>The following code demonstrates how to produce CSV files with dynamic&lt;br /&gt;file name pattern based on a current day. The produced files have the following naming format:&lt;br /&gt;TABLE_NAME_MM_DD_YYYY.csv&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;    &lt;properties&gt; &lt;!-- Configure table name --&gt;&lt;br /&gt;        table_name=test&lt;br /&gt;    &lt;/properties&gt;&lt;br /&gt;    &lt;connection id="in" driver="auto" url="jdbc:oracle:thin:@localhost:1521:ORCL" &lt;br /&gt;      classpath="ojdbc14.jar" user="scott" password="tiger"/&gt;&lt;br /&gt;    &lt;connection id="out" driver="csv" url="${table_name}_${etl.date.now('MM_dd_yyyy')}.csv" /&gt;&lt;br /&gt;    &lt;query connection-id="in"&gt; &lt;!-- Query table rows --&gt;&lt;br /&gt;        SELECT * FROM ${table_name}&lt;br /&gt;        &lt;script connection-id="out"&gt; &lt;!-- Export each row into a CSV --&gt;&lt;br /&gt;            $ID, $Name, $Surname &lt;!-- Use column names from selected table --&gt;&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Use &lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL&lt;/a&gt; to run the example. &lt;br /&gt;&lt;br /&gt;See &lt;a href="http://snippets.dzone.com/posts/show/4862"&gt;How to execute an ETL file&lt;/a&gt; from command line, Ant or directly from Java .</description>
      <pubDate>Fri, 16 Nov 2007 21:08:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4790</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
    <item>
      <title>Importing XML into a database with Scriptella ETL</title>
      <link>http://snippets.dzone.com/posts/show/3534</link>
      <description>The following &lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL&lt;/a&gt; simple usage example imports RSS file into a database table.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;    &lt;connection id="in" driver="xpath" url="http://snippets.dzone.com/rss"/&gt;&lt;br /&gt;    &lt;connection id="db" driver="hsqldb" url="jdbc:hsqldb:db/rss" user="sa" classpath="hsqldb.jar"/&gt;&lt;br /&gt;classpath="hsqldb.jar"/&gt;&lt;br /&gt;    &lt;query connection-id="in"&gt;&lt;br /&gt;        /rss/channel/item&lt;br /&gt;        &lt;script connection-id="db"&gt;&lt;br /&gt;            INSERT INTO Rss (ID, Title, Description, Link) &lt;br /&gt;            VALUES (?rownum, ?title, ?description, ?link);&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here is the full version of the example described above. It creates an RSS table, downloads rss file, inserts rss records into a database, converts rss.xml to a plain text file and saves it to rss.txt.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;    &lt;connection id="in" driver="xpath" url="http://snippets.dzone.com/rss"/&gt;&lt;br /&gt;    &lt;connection id="out" driver="text" url="rss.txt"/&gt;&lt;br /&gt;    &lt;connection id="db" driver="hsqldb" url="jdbc:hsqldb:db/rss" user="sa" classpath="hsqldb.jar"/&gt;&lt;br /&gt;    &lt;script connection-id="db"&gt;&lt;br /&gt;       CREATE TABLE Rss (&lt;br /&gt;           ID Integer,&lt;br /&gt;           Title VARCHAR(255),&lt;br /&gt;           Description VARCHAR(255),   &lt;br /&gt;           Link VARCHAR(255)&lt;br /&gt;&lt;br /&gt;       )&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;    &lt;query connection-id="in"&gt;&lt;br /&gt;        /rss/channel/item&lt;br /&gt;        &lt;script connection-id="out"&gt;&lt;br /&gt;            Title: $title&lt;br /&gt;            Description: [&lt;br /&gt;            ${description.substring(0, 20)}...&lt;br /&gt;            ]&lt;br /&gt;            Link: $link&lt;br /&gt;            ----------------------------------&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;        &lt;script connection-id="db"&gt;&lt;br /&gt;            INSERT INTO Rss (ID, Title, Description, Link) &lt;br /&gt;            VALUES (?rownum, ?title, ?description, ?link);&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 18 Feb 2007 19:07:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3534</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
    <item>
      <title>Script to insert BLOB from file into a database</title>
      <link>http://snippets.dzone.com/posts/show/3533</link>
      <description>&lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL&lt;/a&gt; allows inserting files into a database. This is achieved by a simple bind variables extension syntax ?{file ...}. &lt;br /&gt;The following sample initializes table of music tracks. Each track has a DATA field containing a file loaded from an external location. File song1.mp3 is stored in the same directory as etl.xml and song2.mp3 is loaded from the web:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    &lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;    &lt;etl&gt;&lt;br /&gt;        &lt;connection driver="hsqldb" url="jdbc:hsqldb:file:tracks" user="sa" classpath="hsqldb.jar"/&gt;&lt;br /&gt;        &lt;script&gt;&lt;br /&gt;            CREATE TABLE Track (&lt;br /&gt;              ID INT,&lt;br /&gt;              ALBUM_ID INT,&lt;br /&gt;              NAME VARCHAR(100),&lt;br /&gt;              DATA LONGVARBINARY&lt;br /&gt;            );&lt;br /&gt;            &lt;!-- Inserts file with path relative to ETL script location --&gt;&lt;br /&gt;            INSERT INTO Track(id, album_id, name, data) VALUES&lt;br /&gt;                   (1, 1, 'Song1.mp3', ?{file 'song1.mp3'});&lt;br /&gt;            &lt;!-- Inserts file from an external URL--&gt;&lt;br /&gt;            INSERT INTO Track(id, album_id, name, data) VALUES&lt;br /&gt;                   (2, 2, 'Song2.mp3', ?{file 'http://musicstoresample.com/song2.mp3'});&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 18 Feb 2007 18:26:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3533</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
    <item>
      <title>Copy table from one database to another</title>
      <link>http://snippets.dzone.com/posts/show/3511</link>
      <description>This &lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL&lt;/a&gt; script copies all rows from &lt;b&gt;Src_Table&lt;/b&gt; to &lt;b&gt;Dest_Table&lt;/b&gt;.&lt;br /&gt;&lt;b&gt;Src_Table&lt;/b&gt; contains the following columns: &lt;b&gt;id, first_name, last_name&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Dest_Table&lt;/b&gt; contains the following columns: &lt;b&gt;id, name&lt;/b&gt;&lt;br /&gt;The &lt;b&gt;name&lt;/b&gt; column of the Dest_Table is produced by a concatenation of &lt;b&gt;first_name&lt;/b&gt; and &lt;b&gt;last_name&lt;/b&gt; from the &lt;b&gt;Src_Table&lt;/b&gt;&lt;br /&gt;This example demonstrates HSQLDB-To-Oracle copy procedure, although it works between virtually any databases.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;  &lt;connection id="in" driver="hsqldb" url="jdbc:hsqldb:file:demo" &lt;br /&gt;              classpath="hsqldb.jar" user="sa"/&gt;&lt;br /&gt;  &lt;connection id="out" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:ORCL" &lt;br /&gt;              classpath="ojdbc14.jar" user="scott" password="tiger"/&gt;&lt;br /&gt;  &lt;!-- Copy all table rows from one to another database --&gt;&lt;br /&gt;  &lt;query connection-id="in"&gt;&lt;br /&gt;      SELECT * FROM Src_Table --Selects all rows&lt;br /&gt;      &lt;!-- For each row executes insert --&gt;  &lt;br /&gt;      &lt;script connection-id="out"&gt; &lt;br /&gt;          INSERT INTO Dest_Table(ID, Name) &lt;br /&gt;          VALUES (?id,?{first_name+' '+last_name})&lt;br /&gt;      &lt;/script&gt;&lt;br /&gt;  &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 13 Feb 2007 18:06:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3511</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
    <item>
      <title>Load CSV data into a database (Scriptella ETL tool)</title>
      <link>http://snippets.dzone.com/posts/show/3508</link>
      <description>This example demonstrates usage of &lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL Tool&lt;/a&gt; to load CSV data into a database table.&lt;br /&gt;&lt;br /&gt;Input CSV file data.csv:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;id,priority,summary,status&lt;br /&gt;1,Critical,NullPointerException in Main class,Open&lt;br /&gt;5,Low,"Checkstyle, PMD, Findbugs issues",Reopened&lt;br /&gt;7,Low,Maven integration,Open&lt;br /&gt;10,High,SPI API,Closed&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The CSV loading script has the following content:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;  &lt;connection id="in" driver="csv" url="data.csv"/&gt;&lt;br /&gt;  &lt;connection id="out" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:ORCL" &lt;br /&gt;      classpath="ojdbc14.jar" user="scott" password="tiger"/&gt;&lt;br /&gt;  &lt;!-- Copy all CSV rows to a database table --&gt;&lt;br /&gt;  &lt;query connection-id="in"&gt;&lt;br /&gt;      &lt;!-- Empty query means select all columns --&gt;&lt;br /&gt;      &lt;script connection-id="out"&gt;&lt;br /&gt;          INSERT INTO Table_Name VALUES (?id,?priority, ?summary, ?status)&lt;br /&gt;      &lt;/script&gt;&lt;br /&gt;  &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Use RegEx to filter CSV data:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;query connection-id="in"&gt;&lt;br /&gt;    &lt;!--Select bugs with status open or reopened.--&gt;&lt;br /&gt;    ,,,open|reopened&lt;br /&gt;    &lt;!--Inserts imported rows into a database--&gt;&lt;br /&gt;    &lt;script connection-id="out"&gt;&lt;br /&gt;       INSERT INTO Table_Name VALUES (?id, ?priority, ?summary, ?status);&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;&lt;/query&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 13 Feb 2007 09:42:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3508</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
    <item>
      <title>JDBC 101</title>
      <link>http://snippets.dzone.com/posts/show/2095</link>
      <description>// Note the use of a prepared statement. You can gain a couple of different benefits&lt;br /&gt;// from using a prepared statement versus a conventional statement. One is that the&lt;br /&gt;// database can compile the statement once and simply insert different values into the&lt;br /&gt;// variables each time you call it. For frequently used functions this can result in&lt;br /&gt;// improved performance. The second advantage is where the values to be passed in might&lt;br /&gt;// be changable by hostile users (e.g. a search term taken from a webpage). In those&lt;br /&gt;// cases assembled SQL strings are suseptible to attack by cleverly phrased inputs but&lt;br /&gt;// prepared statements are not because they are _never_ interpreted as actual SQL, only&lt;br /&gt;// as values for variables.&lt;br /&gt;//&lt;br /&gt;// See my other code snippets "Getting A Data Source From Tomcat" and "Data Source 101"&lt;br /&gt;// for more information on how to get the data source you pass into a routine like this.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    /**&lt;br /&gt;     * In this case the Record object is something we are saving to the database.&lt;br /&gt;     */&lt;br /&gt;    public void persistRecord(DataSource dataSource, &lt;br /&gt;        Record record) throws Exception {&lt;br /&gt;&lt;br /&gt;        Connection conn = null;&lt;br /&gt;        PreparedStatement st = null;&lt;br /&gt;        &lt;br /&gt;        int retVal = 0;&lt;br /&gt;        &lt;br /&gt;        try {&lt;br /&gt;            conn = dataSource.getConnection();&lt;br /&gt;            &lt;br /&gt;            st = conn.prepareStatement("insert into test(a, b) values(?, ?)");&lt;br /&gt;&lt;br /&gt;            st.setInt(1, record.getA());&lt;br /&gt;            st.setString(2, record.getB());&lt;br /&gt;            &lt;br /&gt;            int records = st.executeUpdate();&lt;br /&gt;        } catch (SQLException se) {&lt;br /&gt;            log.error(se, se);&lt;br /&gt;            throw se;&lt;br /&gt;        } finally {&lt;br /&gt;            UtilityJDBC.closeSQLClasses(conn, st, null);   &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * NOTE!! if you close a statement the associated ResultSet&lt;br /&gt;     * is closed too so you should copy the contents to some other&lt;br /&gt;     * object. The result set is invalidated also if you recycle a&lt;br /&gt;     * Statement and try to execute some other query before the result&lt;br /&gt;     * set has been completely examined.&lt;br /&gt;     * &lt;br /&gt;     * @param conn&lt;br /&gt;     * @param st&lt;br /&gt;     * @param rs&lt;br /&gt;     * @throws SQLException&lt;br /&gt;     */&lt;br /&gt;    public static void closeSQLClasses(Connection conn, Statement st,&lt;br /&gt;        ResultSet rs) {&lt;br /&gt;&lt;br /&gt;        try {&lt;br /&gt;            if (rs != null) {&lt;br /&gt;                rs.close();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if (st != null) {&lt;br /&gt;                st.close();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if (conn != null) {&lt;br /&gt;                conn.close();&lt;br /&gt;            }&lt;br /&gt;        } catch (SQLException se) {&lt;br /&gt;            log.error(se, se);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 24 May 2006 23:54:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2095</guid>
      <author>JohnMunsch (John Munsch)</author>
    </item>
    <item>
      <title>Open a JDBC connection</title>
      <link>http://snippets.dzone.com/posts/show/2015</link>
      <description>This opens a JDBC connection givine a driver class name, database URL, user name and password. It is possible this method is deprecated and some newer procedure is preferred. I need to look into that.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    /*&lt;br /&gt;    ** driverClass is the JDBC driver class name as a String.&lt;br /&gt;    */&lt;br /&gt;&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;	Class.forName (driverClass);&lt;br /&gt;	connection = DriverManager.getConnection (url,&lt;br /&gt;	    userName, password);&lt;br /&gt;	connection.setAutoCommit (false);&lt;br /&gt;    }&lt;br /&gt;    catch (SQLException ex)&lt;br /&gt;    {&lt;br /&gt;	/*&lt;br /&gt;	** "Connect error"...&lt;br /&gt;	*/&lt;br /&gt;    }&lt;br /&gt;    catch (java.lang.ClassNotFoundException ex)&lt;br /&gt;    {&lt;br /&gt;	/*&lt;br /&gt;	** "Driver error"...&lt;br /&gt;	*/&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 14 May 2006 20:31:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2015</guid>
      <author>mikewilsonuk (Mike Wilson)</author>
    </item>
    <item>
      <title>Execute arbitary SQL in JDBC &amp; get column names etc from the meta data</title>
      <link>http://snippets.dzone.com/posts/show/2014</link>
      <description>This will execute an arbitary SQL string in JDBC and extract the column names. I extracted this code from a much larger module I wrote years ago, so it isn't complete and hasn't been tested. You have been warned.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    /*&lt;br /&gt;    ** connection is a java.sql.Connection obtained in the usual way.&lt;br /&gt;    */&lt;br /&gt;&lt;br /&gt;    PreparedStatement statement =&lt;br /&gt;	connection.prepareStatement (sqlString);&lt;br /&gt;    statement.setMaxRows (configModel.getMaxRows ());&lt;br /&gt;&lt;br /&gt;    if (statement.execute ())&lt;br /&gt;    {&lt;br /&gt;	ResultSet resultSet = statement.getResultSet ();&lt;br /&gt;	ResultSetMetaData metaData = resultSet.getMetaData ();&lt;br /&gt;&lt;br /&gt;	/*&lt;br /&gt;	** Get the column names.&lt;br /&gt;	*/&lt;br /&gt;&lt;br /&gt;	for (int i = 0 ; i &lt; metaData.getColumnCount () ; i++)&lt;br /&gt;	{&lt;br /&gt;	    int columnType = metaData.getColumnType (i + 1);&lt;br /&gt;	    String columnName = metaData.getColumnLabel (i + 1);&lt;br /&gt;&lt;br /&gt;	    /*&lt;br /&gt;	    ** Do something with columnType &amp; columnName.&lt;br /&gt;	    */&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/*&lt;br /&gt;	** Fetch the rows.&lt;br /&gt;	*/&lt;br /&gt;&lt;br /&gt;	while (resultSet.next ())&lt;br /&gt;	{&lt;br /&gt;	    String value;&lt;br /&gt;&lt;br /&gt;	    for (int i = 0 ; i &lt; metaData.getColumnCount () ; i++)&lt;br /&gt;		value = resultSet.getString (i + 1);&lt;br /&gt;	}&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;	/*&lt;br /&gt;	** Query was probably update/insert/delete.&lt;br /&gt;	*/&lt;br /&gt;&lt;br /&gt;	int rowCount = statement.getUpdateCount ();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    statement.close ();&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 14 May 2006 20:25:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2014</guid>
      <author>mikewilsonuk (Mike Wilson)</author>
    </item>
    <item>
      <title>Getting A Data Source From Tomcat</title>
      <link>http://snippets.dzone.com/posts/show/1595</link>
      <description>// You can setup a data source in tomcat using a context file&lt;br /&gt;// or you can set one up using the Administration web pages&lt;br /&gt;// as well. Either way you do it, here is the simple code to&lt;br /&gt;// get the data source from Tomcat so you can start pulling&lt;br /&gt;// out database connections.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// Obtain our environment naming context&lt;br /&gt;Context initCtx = new InitialContext();&lt;br /&gt;Context envCtx = (Context) initCtx.lookup("java:comp/env");&lt;br /&gt;&lt;br /&gt;// Look up our data source by the name we gave it when we created it. &lt;br /&gt;// In this case that's "jdbc/EmployeeDB".&lt;br /&gt;DataSource ds = (DataSource) envCtx.lookup("jdbc/EmployeeDB");&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 28 Feb 2006 04:13:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1595</guid>
      <author>JohnMunsch (John Munsch)</author>
    </item>
    <item>
      <title>Data Source 101</title>
      <link>http://snippets.dzone.com/posts/show/1594</link>
      <description>// Way too many people hard code their JDBC connections to &lt;br /&gt;// the database server(s). Use data sources to connect to&lt;br /&gt;// your databases. They can be setup easily in any major&lt;br /&gt;// Java application server as well as JSP/servlet engines&lt;br /&gt;// like Tomcat and Spring.&lt;br /&gt;//&lt;br /&gt;// If you aren't running inside a container that provides&lt;br /&gt;// you with easy access to a data source though, you can&lt;br /&gt;// include the Jakarta Commons DBCP library and create a&lt;br /&gt;// data source as shown in the code below. The result is&lt;br /&gt;// a data source complete with pooling, caching, etc. that&lt;br /&gt;// you can pass to other code that just expects to receive&lt;br /&gt;// a data source.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;BasicDataSource dataSource = new BasicDataSource();&lt;br /&gt;&lt;br /&gt;dataSource.setDriverClassName(System.getProperty("driverClassName"));&lt;br /&gt;dataSource.setUsername(System.getProperty("username"));&lt;br /&gt;dataSource.setPassword(System.getProperty("password"));&lt;br /&gt;dataSource.setUrl(System.getProperty("url"));&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 28 Feb 2006 04:10:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1594</guid>
      <author>JohnMunsch (John Munsch)</author>
    </item>
  </channel>
</rss>
