Results 1 to 8 of 8
Like Tree4Likes
  • 1 Post By jocdrew21
  • 1 Post By benji2505
  • 1 Post By SurfMan
  • 1 Post By SurfMan

Thread: Java and MySQL

  1. #1
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Java and MySQL

    (I am PHP Programmer and new to Java)
    I know that I must Install MySQL (about 250MB) on my PC to use it in my Java.
    I know I need Connector/J Jar library to connect to MySQL.
    1. Is this the only way to use MySQL in Java?
    2. Do I have to install MySQL on client PC?
    3. No way to make my app without this need to MySQL.
    4. How can code to run MySQL before running my connection codes?

  2. #2
    jocdrew21 is offline Senior Member
    Join Date
    Jan 2014
    Posts
    137
    Rep Power
    0

    Default Re: Java and MySQL

    Is this the only way to use MySQL in Java?
    Yes you need the jar file to be able to access MySQL. Mac, PC and Linix all have different was to access it, google has it all.

    How can code to run MySQL before running my connection codes?
    I would use the singleton design method, if you do not it check out Cave of Programming it's free.

    Do I have to install MySQL on client PC
    yup

    No way to make my app without this need to MySQL
    You do not have to use MYSQL...

    PHP is a very forgiving language, however you will see some similar things in Java as to PHP. Lots of frameworks and styles to learn as long with the syntax. But it is by far my favorite!
    miladrahimi93 likes this.

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    6

    Default Re: Java and MySQL

    you could install mysql on a host and connect via jdbc. You need to install the driver locally. There is years worth of reading material available online.

    you will have to set up mysql to allow access from remote locations and then grant permissions to the remote user. Check this:

    http://stackoverflow.com/questions/1...ql-server-jdbc
    Last edited by benji2505; 12-12-2014 at 10:22 PM.
    miladrahimi93 likes this.

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Java and MySQL

    1. Is this the only way to use MySQL in Java?
    Using the JDBC driver, yes.

    2. Do I have to install MySQL on client PC?
    NO, only on the server

    3. No way to make my app without this need to MySQL.
    Explain

    4. How can code to run MySQL before running my connection codes?
    Easiest is to run it as a service.
    miladrahimi93 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Java and MySQL

    Quote Originally Posted by jocdrew21 View Post
    Do I have to install MySQL on client PC
    yup
    There is no need to install MySQL on the client PC. Only the jar file is needed.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  6. #6
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Re: Java and MySQL

    What is Jar file for MySQL which I need to install on client PC? How can I download it? How much MB is it?

  7. #7
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Java and MySQL

    For all your "HOW" questions: https://duckduckgo.com/?q=mysql+jdbc

    Download: https://dev.mysql.com/downloads/connector/j/

    Installing: https://dev.mysql.com/doc/connector-...nstalling.html

    I know you're not looking for a job, but one of the things I look for when hiring a developer is a self-supporting attitude. I don't care if they can't tell me directly how to install/use a MySQL JDBC connector. What counts for me is if they are able to research the information they need to get the job done. Your three questions were solved with one query on DuckDuckGo.

    If your question is about Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver, or java.net.ConnectException: Connection refused: connect, please paste the first line of the stacktrace into DDG or Teh Googols. I put 10 bucks on it that the first hit is a link to StackOverflow with an answer that solves your problem.
    miladrahimi93 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  8. #8
    jocdrew21 is offline Senior Member
    Join Date
    Jan 2014
    Posts
    137
    Rep Power
    0

    Default Re: Java and MySQL

    The above post is some really good advice.

Similar Threads

  1. Replies: 2
    Last Post: 04-19-2014, 02:50 PM
  2. Java DB, MySQL and MySQL Connector/J
    By jimihunter007 in forum JDBC
    Replies: 2
    Last Post: 07-30-2012, 05:23 AM
  3. Replies: 4
    Last Post: 03-04-2012, 11:26 PM
  4. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM
  5. java to mysql
    By thamizhisai in forum Advanced Java
    Replies: 1
    Last Post: 04-26-2008, 08:21 AM

Tags for this Thread

Posting Permissions

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