Reputation: 51
I'm getting this error that doesn't allow me to create a table. It says that there is a syntax error.
Code:
@Override
public void create() throws SQLException {
String sqlString = String
.format("create table %s(%s VARCHAR(20), %s VARCHAR(20), %s VARCHAR(50), %s VARCHAR(20), %s VARCHAR(5), %s VARCHAR(10), %s VARCHAR(20), %s VARCHAR(20), primary key (%s) )",
_tableName, ID, DESCRIPTION, STREET, CITY, PROVINCE, POSTALCODE, STOREPHONE, AUTOSERVICEPHONE, ID);
super.create(sqlString);
}
Exception
Exception in thread "main" java.sql.SQLSyntaxErrorException: Syntax error: Encountered "VARCHAR" at line 1, column 133.
...
Upvotes: 0
Views: 1161
Reputation: 425198
An educated guess, but one if your variables is almost certainly blank, or contains a blank.
Ordinarily I'd make this a comment, but it's the only possible cause I can think of.
Print out the SQL string to be sure.
Upvotes: 2
Reputation: 2594
Try to escape your column name, in case some of your column name is reserved word in SQL.
@Override
public void create() throws SQLException {
String sqlString = String
.format("create table [%s] ([%s] VARCHAR(20), [%s] VARCHAR(20)......
Upvotes: 0