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: connection errors

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

    Default connection errors

    This is my first attempt to connect to an existing MSQL DB. This is the code and errors. My main question is how can I put this file on the server and execute it or execute this program from eclipse (what is the proper syntax for url?'). I assume that is causing these errors.
    [code]import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.PreparedStatement;

    public class Main {

    /**
    * @param args
    */
    public static void main(String[] args) throws Exception{
    // TODO Auto-generated method stub

    Class.forname("com.mysql.jdbc.Driver");

    Connection con = DriverManager.getConnection("jdbc:mysql://http;//www.sliditerod.com/", "whitebu4_sliditerod ", "whitebu4_admins" ,"*****"));

    PreparedStatememt statement = con.preparedStatement("select * from xyz");
    ResultSet result = statement.executeQuery();
    while (result.next());
    System.out.println(result.getString(1));

    }

    }
    ERRORS PreparedStatememt cannot be resolved to a type
    The method preparedStatement(String) is undefined for the type Connection


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: connection errors

    You misspelled "PreparedStatement" (you used an 'm' instead of an 'n')
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Shared connection or individual connection?
    By newbie14 in forum Java Networking
    Replies: 6
    Last Post: January 12th, 2013, 04:10 AM
  2. Replies: 3
    Last Post: March 6th, 2012, 03:50 AM
  3. connection
    By sugukrish in forum JDBC & Databases
    Replies: 2
    Last Post: November 5th, 2011, 11:14 PM
  4. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  5. Thread and connection
    By Param in forum Threads
    Replies: 0
    Last Post: April 26th, 2010, 03:43 AM