Results 1 to 8 of 8
  1. #1
    unloki9 is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default How to create jdbc connections?

    can someone here could help me create an jdbc connection and how to use the SELECT statement? im using netbeans thanks.. i was searching on the net but im still confused.

  2. #2
    mi14chal is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default

    What do you use database?

  3. #3
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Quote Originally Posted by unloki9 View Post
    can someone here could help me create an jdbc connection and how to use the SELECT statement? im using netbeans thanks.. i was searching on the net but im still confused.
    which part of tutorials that you read are you confused?

  5. #5
    unloki9 is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Thumbs up

    The connection class..using jdbc driver.. and im using mysql for the database..

    my net beans cant run the class file


    public static connection conn thows MySqlException{
    the codes here.
    }

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're not giving us enough information with which we may be able to help you. Please read the links in my signature below including the one on how to ask questions as it will help you to know what we need to answer your questions.

    Luck.

  7. #7
    unloki9 is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    Sorry for that poor reply I just made I was rushing coz i was having a limited time. I was refering to this code, on where will i put this one in my prgram to connect to my sql and java database.

    private static Connection getConnection()
    {
    Connection con = null;
    try
    {
    Class.forName(“com.mysql.jdbc.Driver”);
    String url = “jdbc:mysql://localhost/Movies”;
    String user = “root”;
    String pw = “NuttMutt”;
    con = DriverManager.getConnection(url, user, pw);
    }
    catch (ClassNotFoundException e)
    {
    System.out.println(e.getMessage());
    System.exit(0);
    }
    catch (SQLException e)
    {
    System.out.println(e.getMessage());
    System.exit(0);
    }
    return con;
    }

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

    Default

    In your case?
    I'd just create a helper class that simply had that static method in it.

    Also, when dealing with exceptions you want to print the stack trace and not just the message. You'll lose too much information otherwise (like where the exception actually occurred).

Similar Threads

  1. Are LAN only connections possible?
    By paul pasciak in forum Networking
    Replies: 1
    Last Post: 10-01-2010, 02:55 AM
  2. Jdbc Connections closed..
    By swati.jyoti in forum New To Java
    Replies: 3
    Last Post: 05-20-2009, 10:45 AM
  3. Java Database Connections
    By javahelp00 in forum New To Java
    Replies: 6
    Last Post: 02-28-2009, 07:41 PM
  4. Replies: 4
    Last Post: 02-04-2009, 03:19 PM
  5. Rejecting connections from a specific IP
    By javaplus in forum Networking
    Replies: 2
    Last Post: 12-21-2007, 02:28 PM

Posting Permissions

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