Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucasdota/jdbc_delete_values
Exercício em Java para treinar como deletar valores no mySQL
https://github.com/lucasdota/jdbc_delete_values
Last synced: 2 days ago
JSON representation
Exercício em Java para treinar como deletar valores no mySQL
- Host: GitHub
- URL: https://github.com/lucasdota/jdbc_delete_values
- Owner: Lucasdota
- Created: 2024-10-17T13:46:14.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-10-17T13:48:03.000Z (3 months ago)
- Last Synced: 2024-10-19T19:34:29.792Z (3 months ago)
- Language: Java
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Exercício em Java para treinar como deletar valores no mySQL
### Programa principal:
```java
package application;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;import db.DB;
import db.DbIntegrityException;public class Program {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement st = null;
try {
conn = DB.getConnection();
st = conn.prepareStatement(
"DELETE FROM department "
+ "WHERE "
+ "Id = ?");
st.setInt(1, 5);
int rowsAffected = st.executeUpdate();
System.out.println("Done! Rows affected: " + rowsAffected);
} catch (SQLException e) {
throw new DbIntegrityException(e.getMessage());
} finally {
DB.closeStatement(st);
DB.closeConnection();
}
}}
```