How to write sql query to create table with unique constraint on 2 columns using jdbc: I try this code and give me "SQLException: Invalid create statement!":
Connection conn = ConnectDB.getConnection();
Statement stmt = null;
try {
String sql = "CREATE TABLE TBL_fonts" +
+ "(char_id int not NULL, "
+ "FW VARCHAR(255), "
+ "code VARCHAR(255), "
+ "character VARCHAR(255), "
+ "CONSTRAINT fontConst UNIQUE(FW,code), "
+ "PRIMARY KEY (char_id))";
stmt = conn.createStatement();
stmt.executeUpdate(sql);
conn.commit();
} catch (SQLException ex) {
ex.printStackTrace();
}