RE:CREARUNPOOLDECONEXIONESENMYSQLUSANDODBCP|||||||
SI EXACTAMENTE mira es a la hora de cargar la aplicacion con el archivo .jocl ya lo puse en el classpath junto con los jars que se usan el jaxp.jar, el sax2.jar que es el que hace el parser de la configuracion xml y no me reconoce el nombre del driver xml que es el que viene segun con las versiones 1.4 para arriba entonces no se si me puedas decir como se llama el nombre del driver xml que viene incluido en la version 1.4.2 mira este es el ejemplo que estoy probando lo baje de la pag de jakarta y asi lo corro:
java -Djdbc.drivers=com.mysql.jdbc.Driver:org.apache.commons.dbcp.PoolingDriver JOCLPoolingDriverExample "jdbc:apache:commons:dbcp:/poolingDriverExample" "SELECT * FROM DUAL"
(no tengo que declarar el classpath en la linea de comandos puesto que ya lo tengo en mis variables del sistema)
y me despliega el sigueinte error:
Creating connection.
org.apache.commons.dbcp.SQLNestedException: Could not parse configuration file
at org.apache.commons.dbcp.PoolingDriver.getConnectionPool(PoolingDriver
.java:114)
at org.apache.commons.dbcp.PoolingDriver.connect(PoolingDriver.java:170)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JOCLPoolingDriverExample.main(JOCLPoolingDriverExample.java:98)
Caused by: org.xml.sax.SAXException: System property org.xml.sax.driver not spec
ified
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
at org.apache.commons.jocl.JOCLContentHandler.parse(JOCLContentHandler.j
ava:332)
at org.apache.commons.jocl.JOCLContentHandler.parse(JOCLContentHandler.j
ava:264)
at org.apache.commons.dbcp.PoolingDriver.getConnectionPool(PoolingDriver
.java:111)
... 4 more
quiere decir que no puede hacer el parsing (analizar) la configuracion del archivo xml que trata de acceder causada por un org.XML.SAX.Exception diciendome que el driver xml no esta especificado entonces trate de correrlo con la propiedad "org.xml.sax.driver" y me sigue desplegando el error quiere decir que no reconoce el driver que le pongo o mas bien no se el nombre exacto que viene incluido con la version que tengo instalada de java o simplemente no lo tiene (estoy trabajando bajo la 1.42_08) entonces no se si tu sepas de esto que me pudieras ayudar te lo agradeceria mucho
gracias................
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
//
// Here's a simple example of how to use the PoolingDriver.
// In this example, we'll construct the PoolingDriver implictly
// using the JOCL configuration mechanism.
//
// Note that there is absolutely nothing DBCP specific about
// this code, it's just straight JDBC. You can simply
// switch connection strings to use the "native" drivers
// directly.
//
//
// To compile this example, you'll need nothing but the JDK (1.2+)
// in your classpath.
//
// To run this example, you'll want:
// * commons-collections.jar
// * commons-pool.jar
// * commons-dbcp.jar
// * the classes for your (underlying) JDBC driver
// * sax2.jar (the SAX 2 API)
// * a SAX2 friendly XML parser (jaxp.jar and parser.jar,
// for example)
// * the JOCL configuration for your database connection pool
// (poolingDriverExample.jocl, for example)
// in your classpath.
//
// Invoke the class using two arguments:
// * the connect string for the JDBC driver (see below)
// * the query you'd like to execute
// You'll also want to ensure your both your underlying JDBC
// driver and the org.apache.commons.dbcp.PoolingDriver
// are registered. You can use the "jdbc.drivers"
// property to do this. Note that jdbc.drivers is colon
// seperated list, on all platforms.
//
// Depending upon your XML parser, you may need to register
// the "default" SAX driver, using the "org.xml.sax.driver"
// property.
//
// For example, to invoke this class with an Oracle driver only
// (no pooling):
//
// java -Djdbc.drivers=oracle.jdbc.driver.OracleDriver \
// -classpath oracle-jdbc.jar:. \
// JOCLPoolingDriverExample
// "jdbc:oracle:thin:scott/tiger@myhost:1521:mysid"
// "SELECT * FROM DUAL"
//
// For pooling:
//
// java -Djdbc.drivers=oracle.jdbc.driver.OracleDriver:org.apache.commons.dbcp.PoolingDriver \
// -classpath commons-collections.jar:commons-pool.jar:commons-dbcp.jar:oracle-jdbc.jar:jaxp.jar:parser.jar:sax2.jar:. \
// JOCLPoolingDriverExample
// "jdbc:apache:commons:dbcp:/poolingDriverExample"
// "SELECT * FROM DUAL"
//
// The last token in DBCP connect string (when suffixed with ".jocl")
// is the resource the PoolingDriver reads as the JOCL configuration.
// See Class.getResource for details on resource loading.
//
public class JOCLPoolingDriverExample {
public static void main(String[] args) {
//
// Just plain-old JDBC.
//
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
System.out.println("Creating connection.");
conn = DriverManager.getConnection(args[0]);
System.out.println("Creating statement.");
stmt = conn.createStatement();
System.out.println("Executing statement.");
rset = stmt.executeQuery(args[1]);
System.out.println("Results:");
int numcols = rset.getMetaData().getColumnCount();
while(rset.next()) {
for(int i=1;i<=numcols;i++) {
System.out.print("\t" + rset.getString(i));
}
System.out.println("");
}
} catch(SQLException e) {
e.printStackTrace();
} finally {
try { rset.close(); } catch(Exception e) { }
try { stmt.close(); } catch(Exception e) { }
try { conn.close(); } catch(Exception e) { }
}
}
}