Here is my sqlite table
CREATE TABLE hello (
id INTEGER PRIMARY KEY AUTOINCREMENT,
import_data text,
export_data text
);
Here is my java code
Connection sqliteConnection = DriverManager.getConnection(db);
PreparedStatement preparedStatement = sqliteConnection.prepareStatement("select * from hello where export_data = ?;");
preparedStatement.setString(1, "ABD19E3C63"); // hex string
ResultSet resultSet = preparedStatement.executeQuery();
resultSet.next();
importData = resultSet.getString("import_data");
System.out.println(importData); // prints nothing although I checked in the sqlite database that it exists.
so importData prints nothing although I can see in the sqlite database that it exists. not sure why?
sqlite query
select hex(import_data) from hello where hex(export_data)="ABD19E3C63"; // This works
The above query works in sqlite although I declared both columns as text
你应该试试这个吗?
PreparedStatement preparedStatement = sqliteConnection.prepareStatement("select * from hello where hex(export_data) = ?;");
You should use looping statement like the following.
while (resultSet.next()) {
String import_data= resultSet.getString("import_data");
System.out.println("Import_data"+import_data);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.