Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. MySQL connection URL issue [modified]

MySQL connection URL issue [modified]

Scheduled Pinned Locked Moved Web Development
databasehelpjavamysqlquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khurram_shahzad
    wrote on last edited by
    #1

    Connection con = DriverManager.getConnection("jdbc:odbc:employee");

    please tell me that the methode of defining this "jdbc:odbc:employee" string. As mentioned in getConnnection detail in netbeans the first part jdbc is fix and the second and the third is subProtocol and subName ... so tell me please what are these three things? I'm accessing MySQL database employee.sql using java servlet ... but i dont know this above mentioned statment mechanism so i m still failed to complete. I've also read some bloges/etc but cant ound detail that clear my queation. So plz me. Also plz tell me that in most of the examples and also in above given statment they defines database in two forms, "jdbc:mysql:employee" or "jdbc:odbc://localhost/employee" so what are these location on computer or on my local mechine so shere i keep database(employee.sql) to refer them like these two ways. THANKS TO ALL HELPERS ...

    modified on Wednesday, July 14, 2010 12:23 AM

    S 1 Reply Last reply
    0
    • K khurram_shahzad

      Connection con = DriverManager.getConnection("jdbc:odbc:employee");

      please tell me that the methode of defining this "jdbc:odbc:employee" string. As mentioned in getConnnection detail in netbeans the first part jdbc is fix and the second and the third is subProtocol and subName ... so tell me please what are these three things? I'm accessing MySQL database employee.sql using java servlet ... but i dont know this above mentioned statment mechanism so i m still failed to complete. I've also read some bloges/etc but cant ound detail that clear my queation. So plz me. Also plz tell me that in most of the examples and also in above given statment they defines database in two forms, "jdbc:mysql:employee" or "jdbc:odbc://localhost/employee" so what are these location on computer or on my local mechine so shere i keep database(employee.sql) to refer them like these two ways. THANKS TO ALL HELPERS ...

      modified on Wednesday, July 14, 2010 12:23 AM

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, did you read this: http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1[^] Seems like a complete explanation of the mysql-jdbc-connectionstring issue. I suggest that you put your connection string into the config so that you can change it while running the site. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      K 1 Reply Last reply
      0
      • S SeMartens

        Hi, did you read this: http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1[^] Seems like a complete explanation of the mysql-jdbc-connectionstring issue. I suggest that you put your connection string into the config so that you can change it while running the site. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        K Offline
        K Offline
        khurram_shahzad
        wrote on last edited by
        #3

        Thanks .. But thing still creates problem to me. In this program they uses database test which is already exist ... where i dont know ..... but in case i create my own database then where i keep it and how to give database path in statment con = DriverManager.getConnection("jdbc:mysql:///test", "root", "secret");

        package com.stardeveloper.example;

        import java.sql.Connection;
        import java.sql.DriverManager;
        import java.sql.SQLException;

        public class JdbcExample2 {

        public static void main(String args[]) {
        Connection con = null;

        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
        
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
        }
        

        }
        }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups