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 2 of 2

Thread: Beginner - Where to put code to connect to database

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Beginner - Where to put code to connect to database

    Hi i've just started learning java recently and I have covered the basics constructors, getters, setters etc but I want to know how to connect to a database, i have the code for it but I do not know where to put the code. Would it go in a getter??? Sorry if this is a silly question but i am new to this


  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: Beginner - Where to put code to connect to database

    You must put the code where you want to get connection to your database. And then simply try executing queries on the database through java and when you are done, close the connection. What's so hard?
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

Similar Threads

  1. connect to mysql database
    By aueddonline in forum JDBC & Databases
    Replies: 5
    Last Post: December 17th, 2011, 02:44 PM
  2. How to connect to a remote database?
    By ace84 in forum JDBC & Databases
    Replies: 4
    Last Post: February 24th, 2011, 02:09 AM
  3. Cant connect with database
    By ronn1e in forum JDBC & Databases
    Replies: 1
    Last Post: January 4th, 2011, 05:45 PM
  4. Cant connect with database
    By ronn1e in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 4th, 2011, 04:09 PM
  5. Need urgent help to connect to Database
    By The Vicky in forum JDBC & Databases
    Replies: 3
    Last Post: November 27th, 2010, 11:09 AM