Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Posts
    18

    Unanswered: How do I determine the URL to the database?

    I have installed and created local MySQL test databases and tables on my Windows 7 PC. In order to connect to the database in Java, I need the parameters of the DriverManager getConnection API which includes the username and password and the URL to the database.

    How do I determine the URL to the database?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    A URL is a Uniform Resource Locator) and can be:-
    an IP address (but that only works if the IP address is fixed), allocating an IP address using DHCP by definition is dymnamic IE variable so you cannot rely on it)
    OR
    a hostname, that hostname you be a fully qualified name:- such as
    dbserver.myorganisation.tld
    OR
    //mycomputer/ it depends on what or how your network is set up. it could be the system / computer name (as identified in the control panel / system and security / system)
    OR
    if the MySQL server is running on the same computer as you are trying access it from then you can use the 'locahost' synonym, LOCALHOST (or its IPv4 equivalent 127.0.0.0)
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    In your case you will be accessing it via localhost (127.0.0.1). The default port for MySQL is 3306. Looking at an example of such a connection in Java

    Code:
          conn = DriverManager.getConnection(
                       "jdbc:" + this.dbms + "://" +
                       this.serverName +
                       ":" + this.portNumber + "/",
                       connectionProps);
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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