| Matric | Name | GitHub Link | Status | |--------|------------------------------|---------------------------|--------| | 2XXXXX | YXXXXXXXXXX | https://github.com/abcde | Yes | | 2XXXXX |NAME STUDENTXXXXXXXXXXXXXXXX | | No |
[SQLITE_ERROR] SQL error or missing database (near "WHERE": syntax error) [SQLITE_ERROR] SQL error or missing database (near "WHERE": syntax error)
package com; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class Update { private Connection connect() { // SQLite connection string String url = "jdbc:sqlite:C://sqlite/db/test2.db"; Connection conn = null; try { conn = DriverManager.getConnection(url); } catch (SQLException e) { System.out.println(e.getMessage()); } return conn; } public void update(String status) { String sql = "UPDATE nameListss SET status = ? , WHERE github = null else ? ,"; try (Connection conn = this.connect(); PreparedStatement pstmt = conn.prepareStatement(sql)) { // set the corresponding param pstmt.setString(1, status); pstmt.setString(1, status); // update pstmt.executeUpdate(); } catch (SQLException e) { System.out.println(e.getMessage()); } } /** * @param args the command line arguments */ public static void main(String[] args) { Update app = new Update(); // update the warehouse with id 3 app.update("No"); app.update("Yes"); } }
UPDATE nameListss SET status = CASE WHEN github is null then ? ELSE ? END;
// set the corresponding param pstmt.setString(1, status); pstmt.setString(1, status);
// set the corresponding param pstmt.setString(1, status); pstmt.setString(2, status);
UPDATE MyTable SET MyColumn = CASE WHEN ISNULL(value) THEN 'No' ELSE 'Yes' END
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)