You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/02/18 11:07:18 UTC

svn commit: r1660584 - in /commons/proper/dbcp/trunk/doc: BasicDataSourceExample.java PoolingDriverExample.java

Author: tn
Date: Wed Feb 18 10:07:17 2015
New Revision: 1660584

URL: http://svn.apache.org/r1660584
Log:
Update examples by using an h2 database instead of oracle.

Modified:
    commons/proper/dbcp/trunk/doc/BasicDataSourceExample.java
    commons/proper/dbcp/trunk/doc/PoolingDriverExample.java

Modified: commons/proper/dbcp/trunk/doc/BasicDataSourceExample.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/BasicDataSourceExample.java?rev=1660584&r1=1660583&r2=1660584&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/doc/BasicDataSourceExample.java (original)
+++ commons/proper/dbcp/trunk/doc/BasicDataSourceExample.java Wed Feb 18 10:07:17 2015
@@ -15,11 +15,12 @@
  * limitations under the License.
  */
 
-import javax.sql.DataSource;
 import java.sql.Connection;
-import java.sql.Statement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
+
+import javax.sql.DataSource;
 
 //
 // Here are the dbcp-specific classes.
@@ -34,7 +35,7 @@ import org.apache.commons.dbcp2.BasicDat
 //
 
 //
-// Note that this example is very similiar to the PoolingDriver
+// Note that this example is very similar to the PoolingDriver
 // example.
 
 //
@@ -58,11 +59,11 @@ import org.apache.commons.dbcp2.BasicDat
 // property to do this.
 //
 // For example:
-//  java -Djdbc.drivers=oracle.jdbc.driver.OracleDriver \
-//       -classpath commons-pool-2.3.jar:commons-dbcp-2.1.jar:oracle-jdbc.jar:commons-logging-1.2.jar. \
-//       PoolingDataSourceExample
-//       "jdbc:oracle:thin:scott/tiger@myhost:1521:mysid"
-//       "SELECT * FROM DUAL"
+//  java -Djdbc.drivers=org.h2.Driver \
+//       -classpath commons-pool2-2.3.jar:commons-dbcp2-2.1.jar:commons-logging-1.2.jar:h2-1.3.152.jar:. \
+//       BasicDataSourceExample \
+//       "jdbc:h2:~/test" \
+//       "SELECT 1"
 //
 public class BasicDataSourceExample {
 
@@ -109,9 +110,7 @@ public class BasicDataSourceExample {
 
     public static DataSource setupDataSource(String connectURI) {
         BasicDataSource ds = new BasicDataSource();
-        ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
-        ds.setUsername("scott");
-        ds.setPassword("tiger");
+        ds.setDriverClassName("org.h2.Driver");
         ds.setUrl(connectURI);
         return ds;
     }

Modified: commons/proper/dbcp/trunk/doc/PoolingDriverExample.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDriverExample.java?rev=1660584&r1=1660583&r2=1660584&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/doc/PoolingDriverExample.java (original)
+++ commons/proper/dbcp/trunk/doc/PoolingDriverExample.java Wed Feb 18 10:07:17 2015
@@ -15,12 +15,17 @@
  * limitations under the License.
  */
 
-import java.sql.DriverManager;
 import java.sql.Connection;
-import java.sql.Statement;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 
+import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.DriverManagerConnectionFactory;
+import org.apache.commons.dbcp2.PoolableConnection;
+import org.apache.commons.dbcp2.PoolableConnectionFactory;
+import org.apache.commons.dbcp2.PoolingDriver;
 //
 // Here are the dbcp-specific classes.
 // Note that they are only used in the setupDriver
@@ -29,11 +34,6 @@ import java.sql.SQLException;
 //
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPool;
-import org.apache.commons.dbcp2.ConnectionFactory;
-import org.apache.commons.dbcp2.PoolableConnection;
-import org.apache.commons.dbcp2.PoolingDriver;
-import org.apache.commons.dbcp2.PoolableConnectionFactory;
-import org.apache.commons.dbcp2.DriverManagerConnectionFactory;
 
 //
 // Here's a simple example of how to use the PoolingDriver.
@@ -58,11 +58,11 @@ import org.apache.commons.dbcp2.DriverMa
 // property to do this.
 //
 // For example:
-//  java -Djdbc.drivers=oracle.jdbc.driver.OracleDriver \
-//       -classpath commons-pool-2.3.jar:commons-dbcp-2.1.jar:oracle-jdbc.jar:commons-logging-1.2.jar. \
+//  java -Djdbc.drivers=org.h2.Driver \
+//       -classpath commons-pool2-2.3.jar:commons-dbcp2-2.1.jar:commons-logging-1.2.jar:h2-1.3.152.jar:. \
 //       PoolingDriverExample \
-//       "jdbc:oracle:thin:scott/tiger@myhost:1521:mysid" \
-//       "SELECT * FROM DUAL"
+//       "jdbc:h2:~/test" \
+//       "SELECT 1"
 //
 public class PoolingDriverExample {
 
@@ -74,7 +74,7 @@ public class PoolingDriverExample {
         //
         System.out.println("Loading underlying JDBC driver.");
         try {
-            Class.forName("oracle.jdbc.driver.OracleDriver");
+            Class.forName("org.h2.Driver");
         } catch (ClassNotFoundException e) {
             e.printStackTrace();
         }