Friday, January 25, 2019
java - Convert date to sql date
Answer
I have a little problem with netbeans and SQL Developer. Failed to move to sql date Date. Netbeans freezes :S
the above error was the casting of date to sql.date.
Any solution? brings me crazy.
I attached pieces of my code and see if you can help me.
(i use jDateChooser)
Main:
java.util.Date d = FechaEntrada.getDate();
java.sql.Date fecha = new java.sql.Date(d.getDate());
Entrada ent= new Entrada(Integer.parseInt(idEntrada.getText()),
Integer.parseInt(idTaquilla.getText()),
Integer.parseInt(Cantidad.getText()),
fecha,
Integer.parseInt(pPrecio.getText()));
CrudEntrada.create(ent);
Crud:
public static boolean create (Entrada entrads) {
String sql = "INSERT INTO ENTRADA VALUES (?, ?, ?, ?, ?)";
int nFilas = 0;
try {
PreparedStatement pstm = ConnectDB.conectar().prepareStatement(sql);
pstm.setInt(1, entrads.getId_entrada());
pstm.setInt(2, entrads.getId_taquilla());
pstm.setInt(3, entrads.getCantidad());
pstm.setDate(4, entrads.getFecha());
pstm.setDouble(5, entrads.getPrecio());
nFilas = pstm.executeUpdate();
.
.
.
.
return (nFilas > 0) ? true : false;
}
Subscribe to:
Post Comments (Atom)
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
I am new to dask and I found so nice to have a module that makes it easy to get parallelization. I am working on a project where I was able ...
-
I’m trying to run the following command that reads JSON from a file and formats it with jq : jq -n -r --arg m $( It produces the des...
No comments:
Post a Comment