Я извлек iOS 6 sms db из резервной копии iTunes моего iPhone. Это sqlite3 db.xerial sqlite-jdbc 3.7.2 возвращает [SQLITE_NOTADB] на OSX Mountain Lion
Когда я запрашиваю его в терминале, он отлично работает:
$ sqlite3 sms.db
sqlite> select * from message;
Но когда я пытаюсь запросить его xerial sqlite-jdbc я получаю [SQLITE_NOTADB].
Это код, я использую:
public class Sample {
public static void main(String[] args) throws ClassNotFoundException {
String dbFilePath = args[0];
File dbFile = new File(dbFilePath);
if (!dbFile.exists()) {
throw new IllegalArgumentException(String.format("%s does not exist", dbFilePath));
}
// load the sqlite-JDBC driver using the current class loader
Class.forName("org.sqlite.JDBC");
Connection connection = null;
try {
// create a database connection
connection = DriverManager.getConnection(String.format("jdbc:sqlite:%s", dbFilePath));
Statement statement = connection.createStatement();
statement.setQueryTimeout(30); // set timeout to 30 sec.
ResultSet rs = statement.executeQuery("select * from message");
while (rs.next()) {
// read the result set
System.out.println(rs.getString("text"));
}
} catch (SQLException e) {
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
} finally {
try {
if (connection != null)
connection.close();
} catch (SQLException e) {
// connection close failed.
System.err.println(e);
}
}
}
}
Я использую xerial SQLite-3.7.2 на JDBC OSX Mountain Lion.
Благодарим вас за советы по установке локального хранилища maven. Я возился с pom.xml и не мог заставить его работать. – Salil