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.

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34

Thread: Small problem, help please?

  1. #26
    Junior Member
    Join Date
    Aug 2011
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    Quote Originally Posted by Norm View Post
    Did you look thru the code you posted a link to? The MysqlManager class definition.
    Did you do a search for "conn =" in that code as I suggested back in post#8?
    What do you mean, did I look through it, the MysqlManager class definition?

    Also, I searched for conn = - and it found a few, but it was just conn = null;

    I also found public static Connection con = null;

    Notice the one N on con, and that con = null; was mentioned in a few files also.

    Lots of people have had it working without going through all this, there must be an easy fix to it.

    How do I give a connection a value. Why can't you just answer that

  2. #27
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Small problem, help please?

    Is your code different from the code at the link you posted? When I copied the code from that site into my editor and did a Search for "conn =" I found this line:
          //conn = DriverManager.getConnection("jdbc:mysql://riotscape.com/riot_forum", "riot_forum", "ryan16");

    That looks like the syntax for creating the object you need.

  3. #28
    Junior Member
    Join Date
    Aug 2011
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    Yes, I have that line.

    It's // commented out, so is that why it's not working? o.O

  4. #29
    Junior Member
    Join Date
    Aug 2011
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    I've just looked at another tutorial thread, and I found this.

    	public synchronized static void createKillDeathConnection() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    				conn = DriverManager.getConnection("jdbc:mysql://ADDRESS:3306/DATABASE","USERNAME","PASSWORD");
    			statement = conn.createStatement();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}

    This uses conn = and the DriverManager part isn't commented out.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Small problem, help please?

    It's // commented out, so is that why it's not working
    The commented out part should NOT have stopped you Searching the file and finding the line the same way that I did it. Since you did not post that line I can only assume that your code is NOT the same as the code at the site that you posted a link to.
    I have no idea why that line is commented out. Ask the person that wrote the code or read the page where the code is posted.
    It does appear to give the needed syntax for creating a Connection object.

  6. #31
    Junior Member
    Join Date
    Aug 2011
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    I found it, but because it was already commented out, I presumed that it was un-needed.
    My code is the same, just I assumed it wasn't needed as I wasn't aware that was what created the syntax for the connection, I'm trying it now, will post back with results in a sec.

  7. #32
    Junior Member
    Join Date
    Aug 2011
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    That didn't work. I've just been reading and it said a lot of people were having troubles with that tutorial, so I'm going to remove it and put a new one I have found in its place, I'll let you know how it goes.

  8. #33
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    your problems is that u need to create a object to connect to the data base. it should look something like this
    Connection conn = DriverManager.getConnection ("jdbc:mysql://where database is","userName of database","password");

  9. #34
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Small problem, help please?

    the con variable should look something like this
    Connection con = DriverManager.getConnection ("jdbc:mysql://localhost/database name","user name for database","password");

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Small help needed
    By javabeg in forum Java Theory & Questions
    Replies: 4
    Last Post: March 15th, 2011, 09:50 AM
  2. keylistener small problem
    By matecno in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 14th, 2010, 08:51 PM
  3. Small Project
    By 3XiLED in forum Paid Java Projects
    Replies: 7
    Last Post: March 1st, 2010, 08:35 AM
  4. small problem ... I need help
    By Ashar in forum Loops & Control Statements
    Replies: 4
    Last Post: December 4th, 2009, 11:26 AM
  5. Small Project Ideas
    By Freaky Chris in forum Project Collaboration
    Replies: 20
    Last Post: August 12th, 2009, 12:49 PM