Mysql URL and Java

Posted on 2011-04-19
Last Modified: 2012-06-21
This question is related to

One of the people that posted said that I needed to change the URL for the database. However, I don't understand how to do this. Can you tell me how it works?
Question by:JCW2
    LVL 47

    Expert Comment

    That is a little bit srrange issue. Your previous question the one to which you refer above was formulated - how do I connect to another database? So in one iof the posts folks commented that in order to connect to another databse you need to change the URL. so you need tio chang URL if you indeed want to connect to anoither database. If you experience some problem (error,etc) please sopecify what it is.
    LVL 86

    Expert Comment

    Please clarify your question

    Author Comment

    I need to understand how to change the "URL" string such that I connect to some other database.
    LVL 47

    Accepted Solution

    That is url you used to connect to your databses in that question quoted above:

    String url = "jdbc:mysql://localhost:3306/university";

    Well, if you have another database, you may have it on different host (so you change "localhost" to host name)
    you may have different database name, (so you chnage "university" to anothe mname), you may sometimes
    have different port, (so you change the port then)

    LVL 92

    Assisted Solution

    It was explained in your other question

    String url = "jdbc:mysql://localhost:3306/university";

    The "localhost" part is the server.  It is currently pointing to the local computer, ie. your computer.  The "university" part is the database name.  "3306" is the port number.  That is the default port for mysql.  Change accordingly.  

    where is the database you want to connect to?

    Author Closing Comment

    Thank you for your help.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now