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: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at db_demo.DB_demo.main(DB_demo.java:6)

  1. #1
    Junior Member
    Join Date
    Jan 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Exception in thread "main" java.lang.Error: Unresolved compilation problem: at db_demo.DB_demo.main(DB_demo.java:6)

    import java.sql.*;

    public class DB_demo {

    public static void main(String[] args) {

    String url = "jdbc:mysql://localhost:3306/de_demo";
    String uname = "root";
    String pwd = "345678";
    String query = "select * from employee";

    Connection con = DriverManager.getConnection(url,uname, pwd);
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery(query);

    rs.next();
    System.out.println("id is " + rs.getInt(1));
    System.out.println("name is " + rs.getString(2));
    System.out.println("salary is " + rs.getInt(3));

    con.close();
    }
    }

  2. #2
    Junior Member
    Join Date
    Jan 2024
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at db_demo.DB_demo.main(DB_demo.java:6)

    The error message you received means that there's a problem with your Java code that's stopping it from compiling correctly. This likely suggests there's something wrong with how you've written the code. Review and correct line 6, check for syntax errors, ensure the MySQL Connector/J jar is in the classpath, and handle SQLExceptions. Use the revised code with proper error handling and indentation provided in the previous response.

    I have found a resource to learn from. https://www.programminghomeworkhelp....va-assignment/ seems to be providing valuable assistance in learning programming concepts. If you have any questions or need further clarification on any topic, feel free to ask!

Similar Threads

  1. Replies: 1
    Last Post: May 20th, 2023, 10:14 AM
  2. Replies: 1
    Last Post: June 14th, 2020, 06:54 AM
  3. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  4. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  5. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM