Java examples for java.sql:Sqlite
fetch Shared Files from sqlite
import java.sql.*; import org.apache.log4j.Logger; public class Main{ public static void main(String[] argv) throws Exception{ String toolName = "java2s.com"; String ownerName = "java2s.com"; System.out.println(fetchSharedFiles(toolName,ownerName)); }/*from ww w . ja v a 2 s .c o m*/ public static String fetchSharedFiles(String toolName, String ownerName) { Connection c = null; String filePath = null; try { Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:excelFiles.db"); c.setAutoCommit(false); PreparedStatement prep = c .prepareStatement("SELECT FilePath FROM SharedFiles WHERE ToolName = ? AND Owner = ?;"); prep.setString(1, toolName); prep.setString(2, ownerName); ResultSet rs = prep.executeQuery(); while (rs.next()) { filePath = rs.getString("FilePath"); } c.close(); } catch (Exception e) { //logger.error( e.getClass().getName() + ": " + e.getMessage() ); } return filePath; } }