SQLite Tutorial
SQLite Tutorial
Storage Description
Class
Syntax:
1. sqlite3 DatabaseName.db
Syntax:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
connect();
}
}
Select records
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
try {
Connection conn = this.connect();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SelectRecords app = new SelectRecords();
app.selectAll();
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
try{
Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setDouble(2, capacity);
pstmt.executeUpdate();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}