Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Apr 2015 17:31:42 +0300
From:      Beeblebrox <zaphod@berentweb.com>
To:        <freebsd-ports@freebsd.org>
Subject:   databases/mysql-connector-java: Looks broken to me
Message-ID:  <20150401173142.1b36d256@rsbsd.rsb>

next in thread | raw e-mail | index | archive | help
I was getting indications that mysql connections through the com.mysql.jdbc=
 driver was not working. So I searched for a test method (included below) a=
nd here are the results.

* Server: mariadb100--10.0.17, jailed, tcp connection. Able to connect thro=
ugh other drivers & using same params.
* Client: mysql-connector-java-5.1.35
* Test code compiled with javac, $ java -cp . jdbc >
com.mysql.jdbc.Driver
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc=
.Driver  # I compile with OPTIONS_UNSET=3D NLS
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:191)
	at jdbc.main(jdbc.java:15)

* Java Test Code:
[code]
import java.sql.*;
import java.util.Properties;
public class jdbc
{
    // The JDBC Connector Class.
    private static final String dbClassName =3D "com.mysql.jdbc.Driver";
    private static final String CONNECTION =3D
                          "jdbc:mysql://192.168.2.110/mydb";
    public static void main(String[] args) throws
                             ClassNotFoundException,SQLException
    {
        System.out.println(dbClassName);
        // Class.forName(xxx) loads the jdbc classes and
        // creates a drivermanager class factory
        Class.forName(dbClassName);
        // Properties for user and password.
        Properties p =3D new Properties();
        p.put("user","mydb");
        p.put("password","");
        // Now try to connect
        Connection c =3D DriverManager.getConnection(CONNECTION,p);
        System.out.println("It works !");
        c.close();
    }
}
[/code]


--=20
FreeBSD_amd64_11-Current_RadeonKMS
Please CC my email when responding, mail from list is not delivered.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150401173142.1b36d256>