Setting up the Mysql Driver

Does anyone know of a good link, regarding the setup of a Mysql jdbc driver on a Unix platform. I need to setup a test page and do not know which *.jar file should be referenced in the classpath. Is it a matter of just downloading the [???] jar file or should I make use of connectors?
Thanx in advance

Hi,
I have been using MySQL with Java on both windows and Linux for a while now. All I had to do was to
1) Download the mm.mysql-2.0.11-bin.jar file from www.mysql.com
2) Include this JAR file in the classpath.
3) Open a connection to the database using code like this:
String driverClass = "org.gjt.mm.mysql.Driver",
String url = "jdbc:mysql://localhost/databaseName",
String user = "root",
String password = "");
Class.forName(driverClass).newInstance();
Connection connection = DriverManager.getConnection(url, user, password);
This should do the job.
If you are looking for an easy way of reading and writing objects in databases, I suggest you take a look at the Mr. Persister API that we are releasing on monday May 3rd. It is free, and it does all the tedious and boring work of JDBC for you, with only 5% overhead compared to custom JDBC code. Mr. Persister was developed on MySQL, so it will also work with your project. Check it out here:
http://www.jenkov.dk/projects/mrpersister/mrpersister.jsp
Kind Regards,
Jakob Jenkov
www.jenkov.com

Similar Messages

  • The MySQL driver exception!!

    Hi guys, I got a problem with the MySQL driver. I have installed the MySQL connector to classpath. Then I wrote a test program to test if the driver is working well. This test program showed very thing is working well. This test program can connect the database and pick up data from there.However, when I wrote another program that must be using MySQL, the exception "com.mysql.jdbc.Driver" occured. That looked like the MySQL driver has not been installed well or is not working well. But how this happened? How can I solve this problem???
    Thanks a lot.

    Hi,thanks a lot for ur reply.
    Another problem in this case is that, I have 2 computers running this "problem" program. Acturely, most of job have been done in 1st machine and this "problem" program works very well. Then for some reasons, I gotta move this "problem" program to 2nd machine. At first, I just move the .class file to 2nd machine, but it appears exception"com.mysql.jdbc.Driver". Then I move all the source code and compile it. It also appears the same exception. Does that mean the classpath in 2nd machine has some problems?
    Thanks for any reply.

  • Why does the put display to sleep setting put the hard drive to sleep

    In the energy options (preferences) for power adapter, I have set the display to sleep after 1 minute but the hard drive is set to never. I do this when I am downloading but don't need to use the macbook. However, the macbook seems to go to sleep anyway - any idea why? Any new settings?
    I've maintained these settings on my Power Book G4 and it puts the display to sleep but keeps the Power Book on while downloading.
    Thanks
    Kru
    Macbook   Mac OS X (10.4.9)  
    Macbook   Mac OS X (10.4.9)  

    May be try magic
    Resetting your Mac's PRAM and NVRAM
    and
    Resetting MacBook and System Management Controller (SMC)

  • I need help setting up the hard drive I'm my TC to upload and download files remotely

    Can anyone tell me how to setup my TC hard drive to access VIA the Internet

    Are you trying to connect using win7?
    If so I have bad news.. it won't work. The TC only exposes AFP to internet.. not SMB. And there is no AFP add on for windows. You can only do it from a Mac.
    People do open SMB to the internet on a strange port.. look it up if you want to infect your system and expose all your files to the internet.. there is no security doing this.. so I refuse to consider it an option.
    The only real way from windows is to get a vpn router.. bridge the TC and use it plugged into the vpn device.. vpn into the network and you can safely use SMB.. you cannot do this directly with the TC. It might well have ipsec for icloud but you cannot access it.

  • Setting options to mysql jdbc driver

    Hello All
    Well According to MYSQL setting the CLIENT_MULTI_STATEMENTS flag onto a
    connection should allow multi statements (eg more than one query pr call)
    But I have no idea how to configure BEA to call mysql with the optional
    parameters?
    (btw tried opt_flags=CLIENT_MULTI_STATEMENTS)
    Oliver Billing

    Joe Weinstein skrev:
    [email protected] wrote:
    Hello All
    Well According to MYSQL setting the CLIENT_MULTI_STATEMENTS flag onto a
    connection should allow multi statements (eg more than one query pr call)
    But I have no idea how to configure BEA to call mysql with the optional
    parameters?
    (btw tried opt_flags=CLIENT_MULTI_STATEMENTS)
    Oliver BillingHi. I assume you're using our connection pools, with the mysql driver.
    You would add the property and it's value to the driver properties list.
    JoeHey Joe
    I did
    CLIENT_MULTI_STATEMENTS = true (looked it up under mysql JDBC driver)
    Doesent work though.
    Thanks anyway

  • Tomcat problem finding MySQL driver when context used

    Hi all.
    I have a context set in tomcat3.3 which allows me to run JSPs saved in TOMCAT_HOME/webapps/examples/jsp from /luc.
    Initially, I had problems using beans when I used the context (the whole thing works ok when I just enter the actual path in the URL).
    I solved that by adding the ...WEB-INF/classes directories to my CLASSPATH. But now that the beans are found, Tomcat is giving errors regarding the mySQL driver I'm using, which is mm-mysql-2.0.11.
    The error is:
    Error: 500
    Location: /luc/validateLogin.jsp
    Internal Servlet Error:
    javax.servlet.ServletException:
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
         at validateLogin_1._jspService(validateLogin_1.java:139)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
         at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
         at org.apache.tomcat.core.Handler.service(Handler.java:235)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
         at java.lang.Thread.run(Thread.java:484)
    Root cause:
    java.lang.NullPointerException:
         at customerProfile.customerProfileBean.validateUser(customerProfileBean.java:135)
         at validateLogin_1._jspService(validateLogin_1.java:98)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
         at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
         at org.apache.tomcat.core.Handler.service(Handler.java:235)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
         at java.lang.Thread.run(Thread.java:484)
    And I've outputted the the following stuff:
    Unable to load driver java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    java.sql.SQLException: No suitable driver
    Remember, this all works fine when I don't use the context.
    In my CLASSPATH, I point to the JAR file:
    /usr/local/jdk1.3.1/lib/mm.mysql-2.0.11/mm.mysql-2.0.11-bin.jar
    Any ideas?

    try moving the mm.mysql-2.0.11-bin.jar file to %TOMCAT_HOME%/common/lib. This should make the classes available to all contexts.

  • How to set up multiple hard drives for video editing?

    I have recently purchase a new custom built PC for video editing with Premiere.
    I have 3 seperate HDD's as I read on one of the forums that I should set up the hard drives as follows:
    one for OS/programs
    one for media
    one for pagefile/scratch/rendors (these are new terms for me and I am not exactly sure what they mean)
    If anybody can help walk me through the steps to set up/program my HDDs properly for editing video for adobe CS5, it would be greatly appreciated.
    I do not know where to begin to set this up as recommended.
    Thanks in advance.

    Todd_Kopriva wrote:
    I go through this in this video:
    http://www.video2brain.com/en/videos-5353.htm
    This video helped a lot. I have configured through my adobe software accordingly. Another user also suggested that I configure redirecting of my swap files through windows. I was unable to figure out how to do that.
    Is that necessary?
    Thanks.
    Your video definately helped.

  • Is Lightroom sending sRGB to the printer driver?

    Hello,
    I've been trying to print something on a color laser printer with Lightroom. Unfortunately, Lightroom doesn't seem to support the profile of the printer, maybe it's a CMYK profile, and so I had to use the option "Profile: managed by printer" in Lightrooms print module.
    In order to set up the printer driver correctly and let him handle the color management, I'd like to know what Lightrooms sends to the printer driver when the option "managed by printer" is set (and when draft mode is off!)
    Thanks in advance

    Jeff Schewe - 12:08am Jan 1, 08 PST (#2 of 8)
    Version 1.0 sent sRGB
    Uh, no...since the beta process, when not using draft mode, Lightroom ALWAYS sent ProProto RGB. Draft mode will send either sRGB or Adobe RGB depending on the settings for the previews.
    Since the OP is printing to a laser printer as opposed to a photo printer, the best bet would be to print using draft mode anyway.
    Jeff,
    You may be right and I am sure you know more about this than I do, but in 1.0 I could print contact sheets to my laser printer with no problems with "managed by printer" selected and draft mode off. Since 1.1 I have not been able to get acceptable results regardless of whether I choose draft mode or not and regardless of the settings in the export module. I would love to solve this as it is the number 1 issue I have with Lightroom.
    Gordon

  • How can I set up the canon printer mf4380dn for macbook pro MD318

    I can not set up the canon printer mf4380dn for macbook pro MD318 even thought I set up the printing driver already. The printer usually work good for printing via windows laptop.
    I tried some way but error appear "unable to verify the printer on your network". I printing IP is available

    Upgrade your RAM to at least 4GB's.  Your machine can support 6GB's, but upgrade to 4GB's first. Regardless of what Apple says, you need at least 4GB's to run Lion properly.

  • Java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver when using RMI

    I am trying to connect to mysql Db through RMI but i am getting this exception.
    When trying to connect to db through a normal class implementation without RMI it is connected succesfully.
    What is causing the problem????
    Thanks in advace

    CLASSPATH, man. The RMI server needs to have the MySQL driver JAR in its CLASSPATH.
    That's usually what that exception means.
    %

  • I downloaded mySQL and mySQL driver NOW  WHAT ?

    I downloaded the mySQL and the mySQL driver. What do I do now ?
    I saw a book "mySQL and PHP for Dummies" . What is PHP ?
    Can you give me direction ?
    (without the "go read the archives" type of non-helpful help ?)
    Thank you in advance
    Stan

    If it's PHP and MySQL you're interested in, why are you posting to a Java forum?
    PHP is a Web scripting language:
    http://www.php.net/
    If you want to use MySQL with Java, you'll have to learn enough about SQL and relational databases to be able to get into MySQL, create some tables and users, and add some data. Then you'll use the MySQL JDBC driver to let your Java app access those database tables and do CRUD operations on them (Create/Read/Update/Delete).
    There's a JDBC tutorial under the Tutorials link to the left on this page.
    Here's a Java app that will let you run any valid SQL statement you wish against any database:
    import java.sql.*;
    import java.util.*;
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    db = new DataConnection(driver, url, username, password);
                    Object result = db.executeSQL(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Clean up the connection
        public void close()
            try
                this.connection.close();
            catch (Exception e)
                ; // do nothing; you've done your best
         * Execute ANY SQL statement
         * @param SQL statement to execute
         * @returns list of row values if a ResultSet is returned,
         * OR an altered row count object if not
         * @throws SQLException if the query fails
        public Object executeSQL(final String sql) throws SQLException
            Object returnValue      = null;
            Statement statement     = this.connection.createStatement();
            boolean hasResultSet    = statement.execute(sql);
            if (hasResultSet)
                ResultSet rs            = statement.getResultSet();
                ResultSetMetaData meta  = rs.getMetaData();
                int numColumns          = meta.getColumnCount();
                List rows               = new ArrayList();
                while (rs.next())
                    Map thisRow = new LinkedHashMap();
                    for (int i = 1; i <= numColumns; ++i)
                        String columnName   = meta.getColumnName(i);
                        Object value        = rs.getObject(columnName);
                        thisRow.put(columnName, value);
                    rows.add(thisRow);
                rs.close();
                statement.close();
                returnValue = rows;
            else
                int updateCount = statement.getUpdateCount();
                returnValue     = new Integer(updateCount);
            return returnValue;
    }Maybe it'll help get you started with Java and JDBC. You're on your own with PHP. - MOD

  • Loading MySQL Driver

    Can anyone tell me how do I load the MySQL driver in JVM. I know Class.forName() method. I am talking about the other way of doing it.
    thx

    The "other" way of doing it is by explicitly calling DriverManager.registerDriver(driver)
    eg DriverManager.registerDriver(new com.mysql.jdbc.Driver());
    This is automatically done by calling Class.forName()

  • Any lightweight version of JDBC or any way to trim the mysql jdbc driver?

    Hi, I am doing an web app in j2ee that also shows an applet in which a virtual 3d map is rendered. the applet is a kind of heavy so downloading it takes many time beucasse it has to download many things. Then I must use a database connection from the database to send things to my web server. The problem is that the jdbc driver is about 500k and I want to minimize the downloading time of the applet, is there any way to get a very very small version of JDBC???
    Or do I have to do my own type 2 jdbc??

    MelGohan wrote:
    The app will be in internet, and the clients will mostly use dial up at 36.6kbps. 500K is important considering they must download about 3 MB of the applet.Eek!
    Why use applets and browsers at all?
    You should have an installer that installs an application on the client box. And that uses TCP over the modem to communicate data and nothing else.
    Other than that it is certainly possible to set up the html pages such that the only down load updated components, and that includes the driver. Your application should be broken into pieces as well.
    By the way you did harden MySQL right? Because if you expose it to the internet directly it is going to get hit.

  • Difficulty Installing the MySQL JDBC Driver

    I am trying to install mySQL JDBC driver "mysql-connector-java-2.0.14.tar.gz" to link up with the mySQL server on a Windows XP OS.
    The error is:
    Cannot find database driver classes
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    I have read the USAGE AND INSTALLATION in the README file, but it can not seem to find these drivers still. I added the location to my PATH variable in the environment variables, and set CLASSPATH= ... as well and still can not find them
    Paths i added to PATH and CLASSPATH variables
    C:\j2sdk1.4.0_01\mysqlconnector.tar
    C:\j2sdk1.4.0_01\JDBC
    I did both methods it suggested, within the JDBC folder are the com and org folders. Anyone offer some suggestions.
    I know some smart person is going to say just use linux, but it is needed for my father and he can barely use MS Windows.
    Cheers for any help

    Dear Java Newsgroup User
    I would like to understand more around the Java and MySQLJDBC Configuration. Because I have some problem trying to install and Testing the MySQL JDBC Connector Driver.
    I use Windows XP Professional.
    I Downloaded and Intalled Sun One Studio to start learning JAVA and Features. This SDK Package make 3 Packages (directories):
    Directory No1 C:\JSDK4\j2sdk1.4.1_02 (JAVA_HOME)
    Directory No2 C:\JSDK4\s1studio (Source Examples ...)
    Directory No3 C:\Archivos de programa\Java\j2re1.4.1_02 (Java R. Env.)
    In the WINDOWS XP PANNEL CONTROL apper Java Plugins Control Pannel also
    when I press or click this icon apper a Java Screen where i can see the following Configuration in the Advanced Option:
    Java RuntTime Enviroment:
    Use Java Plugin Default
    JRE 1.4.1_02 in C:\Archivos de programa\Java\j2re1.4.1_02
    SDK 1.4.1_02 in C:\JSDK4\j2sdk1.4.1_02
    MySQL Driver Confiration and Version:
    This is my Un-ziped MySQL JDBC connector Path:
    C:\JSDK4\j2sdk1.4.1_02\mysql-connector-java-3.0.8-stable
    Into mysql-connector-java-3.0.8-stable directory exist an directory called [testsuite] that have some jar, java and class files.
    Testing MySQL JDBC Connecto Driver and Error Message:
    When i try to run the BaseTestCase.class file the system give me the following ERROR Message:
    C:\JSDK4\j2sdk1.4.1_02\mysql-connector-java-3.0.8-stable\testsuite>java BaseTestCase
    Exception in thread "main" java.lang.NoClassDefFoundError: BaseTestCase (
    ame: testsuite/BaseTestCase)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
    My Question are the following:
    1- What is the meaning of this message error?
    2- What i need to do to solve this problem?
    3- What is the function specificly of the JRE 1.4.1_02 in C:\Archivos de programa\Java\j2re1.4.1_02 Directory in My JAVA Instalation.
    I you need more detail of my instalation please write me and i write back a soon as possible.
    Dear Users:
    Please Help Me! to continue with the next steps ...
    Best Regards and Than's so much for read this message
    From Panama City
    VanyRon

  • I have a new MAcBook Air and my photos don't fit on the internal hard drive.  I want to store my photos on an external hard drive which I will connect to my Air when using Iphoto.  How do I set an external hard drive as the default drive?

    I have a new MAcBook Air and my photos don't fit on the internal hard drive.  I want to store my photos on an external hard drive which I will connect to my Air when using Iphoto.  How do I set an external hard drive as the default drive in Iphoto?

    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

Maybe you are looking for

  • Transitions double 1st frame/drop last frame: a solution

    I have found that Transitions in iMovie 5 are problematic. The first frame in a Transition doubles and the last frame drops out. This is not noticeable in a slideshow but can be very noticeable in an exported video. Transitions cannot be edited frame

  • How to make a BPM restartble at a specific point after error?

    Hi, I have a somewhat very simple question. I have a BPM that works like this: 1. receive message A 2. transform message A to message B (using valuemapping) 3. switch with a condition determining if valuemapping was succesfull for all cases. 3.1. Bra

  • Can I open a port range in the firewall for one host?

    Can I open a port range in the firewall for one host?  In other words, I want to be able to open ports 54001 to 54050 to allow one remote host in my LAN to access that port range in my Mac Server.  Is this possible?  Currently, the only option I see

  • Filler and Skip command in SQL Loader

    Hai Gurus ! Can Any help me to send code for filler and skip command in SQL Loader. and please explain about filler, for what purpose it is used.

  • User license mass change

    We need to classify many of our users in many systems as multi-client. If you do an individual SU01 change on the license tab then multi-client is an option on the drop down. However if you do a mass change (SU10) the multi-client is not on the drop