0

With Netbeans 8.2, It runs perfectly.

But in Eclipse Neon 3, after adding mysql connector jar, still the problem persists

import java.io.FileInputStream;
import java.sql.*;
import java.util.Properties;

public class Table {

    public static void main(String[] args) {

        try {
            FileInputStream f = new FileInputStream("db.properties");
            Properties p = new Properties();
            p.load(f);
            String qry = "Create table Table1(values integer(2) primary key)";
            String driver_name = p.getProperty("Driver");
            String url = p.getProperty("url");
            Class.forName(driver_name);
            Connection c = DriverManager.getConnection(url, p);
            Statement s = c.createStatement();
            s.execute(qry);
            System.out.println("Table created successfully!");
        }

        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
2

1 Answer 1

1

'Values' is a reserved word, so preferably change it or use back ticks to make sure it's dealt with as a column name...

String qry = "Create table Table1(`values` integer(2) primary key)";
Sign up to request clarification or add additional context in comments.

1 Comment

That's not an issue here. I made it back, Thanks for your valuable feedback!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.