My favorites
▼
|
Sign in
lineadecodigo
Web Code Samples in spanish
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
lineadecodigo_java
/
src
/
com
/
lineadecodigo
/
java
/
jdbc
/
BorrarDatos.java
‹r157
r478
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.lineadecodigo.java.jdbc;
/**
* @file BorrarDatos.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 25/agosto/2009
* @url http://lineadecodigo.com/java/borrado-de-datos-con-jdbc
* @description Realizar borrado de datos en una BD mediante DELETE y JDBC.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class BorrarDatos {
public static void main(String[] args) {
Connection con = null;
PreparedStatement stmt = null;
// Definimos el driver y la url
String sDriver = "com.mysql.jdbc.Driver";
String sURL = "jdbc:mysql://localhost:3306/lineadecodigo";
// Cargamos el driver y realizamos la conexión
try{
Class.forName(sDriver).newInstance();
con = DriverManager.getConnection(sURL,"root","");
stmt = con.prepareStatement("DELETE FROM paises");
int retorno = stmt.executeUpdate();
System.out.println(retorno);
} catch (SQLException sqle){
System.out.println("SQLState: "
+ sqle.getSQLState());
System.out.println("SQLErrorCode: "
+ sqle.getErrorCode());
sqle.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
if (con != null) {
try{
stmt.close();
con.close();
} catch(Exception e){
e.printStackTrace();
}
}
}
}
}
Show details
Hide details
Change log
r356
by vcuervo on Mar 26, 2011
Diff
JDBC
Go to:
...o/java/jdbc/ActualizarDatos.java
...odigo/java/jdbc/BorrarDatos.java
...java/jdbc/ConexionBaseDatos.java
...igo/java/jdbc/InsertarDatos.java
Project members,
sign in
to write a code review
Older revisions
r157
by vcuervo on Aug 24, 2009
Diff
Borrar datos con JDBC y DELETE.
All revisions of this file
File info
Size: 1573 bytes, 59 lines
View raw file
Powered by
Google Project Hosting