import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class ConnectToSqlite {
public static void main(String[] args) throws Exception {
//Connect to the database
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\josep\\Documents\\GitHub\\Java-Training\\Java-Training\\src\\main\\resources\\sqlite.db");
//Create a statement object
Statement stmt = conn.createStatement();
//Execute the query and store the result in a ResultSet object
ResultSet rs = stmt.executeQuery("SELECT * FROM example");
//Iterate through the result set and print the values
List<String> list = new ArrayList<String>();
while (rs.next()) {
list.add(rs.getString("name"));
}
System.out.println(list);
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)