-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
What steps will reproduce the problem?
Class.forName(org.sqlite.JDBC.class.getCanonicalName());
String url = "jdbc:sqlite:";
SQLiteConfig config = new SQLiteConfig();
config.setEncoding(SQLiteConfig.Encoding.UTF8);
Connection conn = DriverManager.getConnection(url, config.toProperties());
What is the expected output?
- a new Connection object instance
What do you see instead?
- an SQLException (see below)
java.sql.BatchUpdateException: batch entry 1: [SQLITE_ERROR] SQL error or
missing database (near "-": syntax error)
What version of the product are you using?
- sqlite-jdbc-3.7.2.jar
- compiled from source (branch: default, commit: f6429dadc828)
On what operating system?
Debian GNU/Linux "wheezy" (testing)
Please provide any additional information below.
The cause of the problem is to be found in SQLiteConfig.apply(Connection):
String sql = String.format("pragma %s=%s", key, value);
In the above example (which results in an SQLException) the parameters have the
following values:
String key = "encoding";
String value = "UTF-8";
So the String sql becomes:
String sql = "pragma encoding=UTF-8";
But trying to execute this is futile as UTF-8 has to be enclosed in quotation
marks for the sql-parser:
String sql = "pragma encoding=\"UTF-8\"";
Original issue reported on code.google.com by matthias...@gmx.de on 5 May 2012 at 4:51