Results 1 to 2 of 2
  1. #1
    peiceonly is offline Member
    Join Date
    Mar 2007
    Posts
    41
    Rep Power
    0

    Default Data Source :How to get connection inside java

    Hi all

    How is the java code different if we use the datasource or simple connections ?

    I will make it little more clear , I make an ordinary connection using JDBC and later i thought of configuring it in the datasource.xml .How s the get connection method in the java code different

    thanks
    peiceonly

  2. #2
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    ferosh please paste code inside '[ code ] [ /code ]' block

    Java Code:
    
    public Connection getDb() throws ClassNotFoundException, SQLException
    {
    Connection con=null;
    try
    {
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    con = DriverManager.getConnection("jdbc:mysql://localhost/mytest?user=root&password=lroot");
    // System.out.println("Connection is established");
    }
    catch(Exception e)
    {
    System.out.println("Exception in Connection "+ e);
    }
    return con;
    }

Similar Threads

  1. Replies: 0
    Last Post: 01-03-2008, 12:28 PM
  2. Replies: 0
    Last Post: 12-24-2007, 09:47 AM
  3. Problem for iReport (Data Source )
    By tlgkumar in forum Advanced Java
    Replies: 1
    Last Post: 11-27-2007, 07:39 AM
  4. 2 threads sharing a data base connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 04:41 AM
  5. Connection to data base
    By Daniel in forum JDBC
    Replies: 2
    Last Post: 06-07-2007, 04:55 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
  •