36 lines
1.3 KiB
Java
36 lines
1.3 KiB
Java
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
|
|
public class update_theme {
|
|
public static void main(String[] args) {
|
|
String url = "jdbc:oracle:thin:@localhost:1521/sisvietnam";
|
|
String user = "sisvietnam";
|
|
String password = "sisvietnam";
|
|
|
|
try (Connection conn = DriverManager.getConnection(url, user, password)) {
|
|
// Let's first see what's in sis_setting
|
|
try (PreparedStatement checkStmt = conn.prepareStatement("SELECT ID, THEME FROM sis_setting")) {
|
|
ResultSet rs = checkStmt.executeQuery();
|
|
while (rs.next()) {
|
|
System.out.println("ID: " + rs.getLong("ID") + ", THEME: " + rs.getString("THEME"));
|
|
}
|
|
} catch (Exception e) {
|
|
System.out.println("Error reading theme: " + e.getMessage());
|
|
}
|
|
|
|
// Update theme
|
|
String updateQuery = "UPDATE sis_setting SET THEME = 'umass'";
|
|
try (PreparedStatement updateStmt = conn.prepareStatement(updateQuery)) {
|
|
int rows = updateStmt.executeUpdate();
|
|
System.out.println("Rows updated: " + rows);
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|