commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Tripodi (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (DBUTILS-96) dynamic load jdbc jars use Dbutils,it say No suitable driver found for jdbc
Date Fri, 27 Jul 2012 13:28:41 GMT

     [ https://issues.apache.org/jira/browse/DBUTILS-96?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Simone Tripodi updated DBUTILS-96:
----------------------------------

    Description: 
By this way(use Dbutil get connect),it will say: {{No suitable driver found for jdbc:mysql://127.0.0.1:3306/xxx}}

{code}
urls = new URL[1];
urls[0] = new File("d:\mysql_connector_5.1.15_bin.jar").toURL();
URLClassLoader urlClassLoader= new URLClassLoader(urls, ClassLoader.getSystemClassLoader())
	
DbUtils.loadDriver(urlClassLoader, driver);

Properties conProps = new Properties(); 
conProps.put("user", user); 
conProps.put("password", pwd); 
conProps.put("defaultRowPrefetch", "20");

scanedConnection = DriverManager.getConnection(url, conProps);
{code}

but by this way (use jdbc's api get connect),it's ok

{code}
try {
    URL jdbcDriverURL = new File("d:\\mysql_connector_5.1.15_bin.jar").toURL();
    URL[] urls = new URL[1];
    urls[0] = jdbcDriverURL;
    URLClassLoader urlclassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
    try {
        java.sql.Driver driverd = (java.sql.Driver) urlclassLoader.loadClass(driver).newInstance();
        System.out.println(driverd.toString());
        Properties props = new Properties();
        props.setProperty("user", theUser);
        props.setProperty("password", thePw);
        try {
            c = driverd.connect(dbUrl, props);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (IllegalAccessException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}//

} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
{code}

is this a bug or my useing falut?

  was:
By this way(use Dbutil get connect),it will say: {{No suitable driver found for jdbc:mysql://127.0.0.1:3306/xxx}}

{code}
urls = new URL[1];
urls[0] = new File("d:\mysql_connector_5.1.15_bin.jar").toURL();
URLClassLoader urlClassLoader= new URLClassLoader(urls,ClassLoader.getSystemClassLoader())
	
DbUtils.loadDriver(urlClassLoader, driver);

Properties conProps = new Properties(); 
conProps.put("user", user); 
conProps.put("password", pwd); 
conProps.put("defaultRowPrefetch", "20");

scanedConnection = DriverManager.getConnection(url, conProps);
{code}

but by this way (use jdbc's api get connect),it's ok

{code}
try {
    URL jdbcDriverURL = new File("d:\\mysql_connector_5.1.15_bin.jar").toURL();
    URL[] urls = new URL[1];
    urls[0] = jdbcDriverURL;
    URLClassLoader urlclassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
    try {
        java.sql.Driver driverd = (java.sql.Driver) urlclassLoader.loadClass(driver).newInstance();
        System.out.println(driverd.toString());
        Properties props = new Properties();
        props.setProperty("user", theUser);
        props.setProperty("password", thePw);
        try {
            c = driverd.connect(dbUrl, props);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (IllegalAccessException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}//

} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
{code}

is this a bug or my useing falut?

    
> dynamic load jdbc jars use Dbutils,it say  No suitable driver found for jdbc
> ----------------------------------------------------------------------------
>
>                 Key: DBUTILS-96
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-96
>             Project: Commons DbUtils
>          Issue Type: Bug
>         Environment: jdk 1.6
>            Reporter: yuyf
>
> By this way(use Dbutil get connect),it will say: {{No suitable driver found for jdbc:mysql://127.0.0.1:3306/xxx}}
> {code}
> urls = new URL[1];
> urls[0] = new File("d:\mysql_connector_5.1.15_bin.jar").toURL();
> URLClassLoader urlClassLoader= new URLClassLoader(urls, ClassLoader.getSystemClassLoader())
	
> DbUtils.loadDriver(urlClassLoader, driver);
> Properties conProps = new Properties(); 
> conProps.put("user", user); 
> conProps.put("password", pwd); 
> conProps.put("defaultRowPrefetch", "20");
> scanedConnection = DriverManager.getConnection(url, conProps);
> {code}
> but by this way (use jdbc's api get connect),it's ok
> {code}
> try {
>     URL jdbcDriverURL = new File("d:\\mysql_connector_5.1.15_bin.jar").toURL();
>     URL[] urls = new URL[1];
>     urls[0] = jdbcDriverURL;
>     URLClassLoader urlclassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
>     try {
>         java.sql.Driver driverd = (java.sql.Driver) urlclassLoader.loadClass(driver).newInstance();
>         System.out.println(driverd.toString());
>         Properties props = new Properties();
>         props.setProperty("user", theUser);
>         props.setProperty("password", thePw);
>         try {
>             c = driverd.connect(dbUrl, props);
>         } catch (SQLException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>     } catch (InstantiationException e) {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
> } catch (IllegalAccessException e) {
>     // TODO Auto-generated catch block
>     e.printStackTrace();
> }//
> } catch (MalformedURLException e1) {
> // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> {code}
> is this a bug or my useing falut?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message