Friday, 25 January 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)
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I got an error in my Java program. I think this happens because of the constructor is not intialized properly. My Base class Program public ...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
No comments:
Post a Comment