Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: oracle conection pool

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    71
    My Mood
    Cheerful
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default oracle conection pool

    I'm creating a WebApp which need a active connection to Database and i have Oracle 11G for that.
    My problem is that i want to access database created in Oracle using application server(Tomcat7)??
    I'm using Netbeans. Can we integrate Oracle in NetBeans??
    Regards
    Last edited by arvindbis; October 26th, 2011 at 09:43 AM. Reason: Providing complete Information


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: oracle conection pool

    Believe me, atleast i couldn't understand what is the problem you are asking for? Be more precise please.

  3. #3
    Member
    Join Date
    Mar 2011
    Posts
    71
    My Mood
    Cheerful
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: oracle conection pool

    i'm creating webapp and it need to access database, for that i just want to create a database connection pool. database is created in oracle 11g. i just don't know how to create that??
    regards

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: oracle conection pool

    Connection connection = null;
    try {
        // Load the JDBC driver
        String driverName = "oracle.jdbc.driver.OracleDriver";
        Class.forName(driverName);
     
        // Create a connection to the database
        String serverName = "127.0.0.1"; // Your database host name
        String portNumber = "1521";  // Communication Port
        String sid = "mydatabase"; // Database sid
        String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
        String username = "username";
        String password = "password";
        connection = DriverManager.getConnection(url, username, password);
    } catch (ClassNotFoundException e) {
        // Could not find the database driver
    } catch (SQLException e) {
        // Could not connect to the database
    }
    Hope this will help.
    Regards...

  5. #5
    Member
    Join Date
    Mar 2011
    Posts
    71
    My Mood
    Cheerful
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: oracle conection pool

    this method of connection is for the desktop application(i guess). well will try! my problem is that how can i configure the server to create a pool and use!
    regards

  6. #6
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,234
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: oracle conection pool

    A pool is just that - a pool. Mr.777 code only creates a connection, not a pool. If you wish to create a pool, then just create a List of connections for clients to grab a Connection from. You have provided little information or context to the problem, so it is guessing to provide context beyond this. If this is a webapp, many application containers already provide libraries to create connection pools - do the research on your particular container if this is the case.

  7. #7
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: oracle conection pool

    Also, your problem lies in the wrong code section, most of the poblems here are desktop oriented. So i was unable to guess.
    Also, you didn't provide enough information.
    Anyways, follow the copeg suggestions.
    Good Luck. And better read this...

  8. #8
    Member
    Join Date
    Mar 2011
    Posts
    71
    My Mood
    Cheerful
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: oracle conection pool

    thank you guys.
    well i updated my question just have a look!
    do i need to create DSN for using it with the Application server??
    @copeg --> indeed even i said that in my reply.

    application containers already provide libraries to create connection pools
    Does this is
    ojdbc14.jar
    what you are pointing to??

    @mr. 777 -->
    Also, your problem lies in the wrong code section, most of the problems here are desktop oriented. So i was unable to guess.
    Also, you didn't provide enough information.
    well i can't undo that, i created thread here because i thought my problem is something related to JDBC/Databases!!

    I think there is enough information provided now, well if you feel there is something missing then do a fav. by asking for it?
    Regards
    Last edited by arvindbis; October 26th, 2011 at 10:04 AM.

  9. #9
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,234
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: oracle conection pool

    well i can't undo that, i created thread here because i thought my problem is something related to JDBC/Databases!!
    Actually, I moved your post to this forum

    Like I said, you can create a pool manually by creating some type of class that manages a list of created connections. See the following link: Chapter 8 Continued: Connection Pooling

    What application container are you using?

  10. The Following User Says Thank You to copeg For This Useful Post:

    arvindbis (October 29th, 2011)

  11. #10
    Member
    Join Date
    Mar 2011
    Posts
    71
    My Mood
    Cheerful
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: oracle conection pool

    i think it is Web container, as i'm new in this field therefore not so sure about these. anyway i'm using tomcat 7, do tell me how to know which container is used??

  12. #11
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: oracle conection pool

    There is no problem with any container you use.
    You can use any one of your choice or your application requirements.

Similar Threads

  1. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  2. Replies: 0
    Last Post: January 12th, 2011, 07:41 AM
  3. thread pool question
    By balexios in forum Threads
    Replies: 3
    Last Post: October 24th, 2010, 03:47 AM
  4. jsp and oracle
    By sri latha in forum JDBC & Databases
    Replies: 0
    Last Post: March 10th, 2010, 08:29 AM
  5. Oracle and Sun
    By copeg in forum The Cafe
    Replies: 2
    Last Post: January 31st, 2010, 06:00 AM