Results 1 to 8 of 8
  1. #1
    Pr0n is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default Driver for Java-SQL

    I am writing a program which writes to and gets information from an SQL database. basically it's a ticket system. A user can create a issue ticket (much like bug tracking) and then using a different client a tech. can retrieve information and add information, all of it being stored in an offsite SQL database.

    now when trying to make the connection to the database using the fallowing code
    Java Code:
        public static Connection getConnection() throws Exception{
    
            Class.forName("com.mysql.jdbc.Driver");
            return DriverManager.getConnection("jdbc:mysql://*****:3306admin_ticket", "****", "****");
        }
    I get a class not found error from the
    <Class.forName("com.mysql.jdbc.Driver");>
    line after doing a lot of reading online I ahve found that there is a 'driver' I need to install. however I have read and googled and read and googled everything I can think of but alas I have found no information on where this driver is supposed to be isntalled. is it installed in the server? is it called from the program is it part of the program? Someone please help fill me in.

    Thanks in advance


    PS incase it's important the server hosting the database is running SQL through phpMyAdmin from within DirectAdmin on top of CentOS. if that makes sense ;) and all of the computers that will be running my program are XP pro
    Last edited by Pr0n; 07-22-2009 at 08:46 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Google for MySQL JDBC driver. You need the right jar file for the version of MySQL you're using. That jar file will need to be added to the classpath for your Java program.

  3. #3
    Pr0n is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default

    I have found the drivers but I haven't been able to find anything that tells me how to add it to the class path (at least that I can understand) can you help me out with that?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    It somewhat depends on the tools you are currently using. Are you compiling from the command line, or are you using an IDE such as NetBeans or Eclipse?

  5. #5
    Pr0n is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default netbeans

    netbeans most updated version

    and anyone know of another place to get the driver mysql.com is down and has been all day.


    [edit]I got the files needed and I'm having trouble figuring out this classpath stuff. I'm running windows XP. how do I get this stupid thing imported
    [edit again]
    I have messed with this classpath crap for hours no to no avail I feel like I've tried every permutation of setting the classpath in the environment variables but it still can't find it. any ideas?
    Last edited by Pr0n; 07-23-2009 at 02:45 AM.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Quote Originally Posted by Pr0n View Post
    netbeans most updated version

    and anyone know of another place to get the driver mysql.com is down and has been all day.


    [edit]I got the files needed and I'm having trouble figuring out this classpath stuff. I'm running windows XP. how do I get this stupid thing imported
    [edit again]
    I have messed with this classpath crap for hours no to no avail I feel like I've tried every permutation of setting the classpath in the environment variables but it still can't find it. any ideas?
    I don't know netbeans, but (taking Eclipse as an example) presumably you can add a jar file to your project which will be picked up when you run the code. Don't faff about with Windows classpaths, stick to working through Netbeans.

  7. #7
    Pr0n is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default wtf

    got it! after hours of screwing with it I finally figured it out. with netbeans you have to go to project properties and add it to the compile and run libraries.



    That.Was.Ridiculous

    yay for 6 hours on one line of code

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    but it's been a valuable lesson that's been learned and will help speed you up when you have to add additional libraries in the future.

Similar Threads

  1. Replies: 6
    Last Post: 09-01-2010, 11:29 AM
  2. Replies: 6
    Last Post: 02-19-2010, 01:57 PM
  3. Replies: 13
    Last Post: 03-16-2009, 09:37 PM
  4. Replies: 4
    Last Post: 02-04-2009, 03:19 PM
  5. Replies: 0
    Last Post: 12-18-2007, 06:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •