Results 1 to 3 of 3
  1. #1
    mallikanala is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Thumbs up different methods to communicate with DB

    1)
    Class.forName("oracle.jdbc.driver.OracleDriver")
    Connection con= DriverManager.getConnection(“jdbc:oracle:thin:@loc alhost:1521:XE","system","malli");


    2) Class.forName("jdbc.odbc.JdbcOdbcDriver")
    Connection con = DriverManager.getConnection("jdbc:odbc:Accounting" ,"dept12", "Julie");

    3) public static synchronized Connection getConnection(String url, String
    user, String password) throws SQLException;
    public static synchronized Connection getConnection(String url);
    public static synchronized Connection getConnection(String url,
    java.util.Properties info);

    java.util.Properties prop = new java.util.Properties();
    prop.put("UID", "dept12");
    prop.put("PWD", "Julie");
    Connection con = DriverManager.getConnection("jdbc:odbc:Accounting" ,
    prop);

    ----------------------------------------------------
    actually i m saw these type of methods .
    but i dont know where i was to use and wt is diff between these

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    Read the API for the DriverManager class; it shows the different ways you can obtain a Connection from the DriverManager.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

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

    Default

    1 and 2 are the same method.
    They just use a different underlying driver.

Similar Threads

  1. communicate with xml-rpc
    By tah_206207 in forum New To Java
    Replies: 2
    Last Post: 04-18-2011, 09:14 PM
  2. trying to communicate between classes
    By rippon in forum New To Java
    Replies: 8
    Last Post: 02-09-2011, 11:20 PM
  3. Communicate JFrame with JDialog
    By BeRniTo in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2009, 02:07 PM
  4. Communicate between Windows and UNIX
    By nwboy74 in forum Networking
    Replies: 10
    Last Post: 11-04-2008, 08:53 PM
  5. Communicate vb.NET with Java
    By cachi in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 12:41 AM

Posting Permissions

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