verán en mi metodo he declarado la variable(Precio) de tipo double y mientras que en mi base de datos numero decimal.Pero no entiendo porque me genera ese mensaje.
mi capa datos
package Datos;
/**
*
* @author
*/
public class vexamenes {
private int Id_examen;
private String Nombre;
private double Precio;
private int Id_grupoExamen;
public vexamenes(int Id_examen, String Nombre, double Precio, int Id_grupoExamen) {
this.Id_examen = Id_examen;
this.Nombre = Nombre;
this.Precio = Precio;
this.Id_grupoExamen = Id_grupoExamen;
}
public vexamenes() {
}
public int getId_examen() {
return Id_examen;
}
public void setId_examen(int Id_examen) {
this.Id_examen = Id_examen;
}
public String getNombre() {
return Nombre;
}
public void setNombre(String Nombre) {
this.Nombre = Nombre;
}
public Double getPrecio() {
return Precio;
}
public void setPrecio(Double Precio) {
this.Precio = Precio;
}
public int getId_grupoExamen() {
return Id_grupoExamen;
}
public void setId_grupoExamen(int Id_grupoExamen) {
this.Id_grupoExamen = Id_grupoExamen;
}
}
mi capa lógica
package Logica;
import Datos.vexamenes;
import java.sql.Connection;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.JOptionPane;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
/**
*
* @author Mayde2
*/
public class hexamenes {
private Conexion access = new Conexion();
private Connection cn= access.conectar();
private String sAccess="";
public Integer totalregistros;
public DefaultTableModel mostrar(String buscar) throws SQLException{
DefaultTableModel modelo;
String [] titulos = {"ID", "Exámen", "Precio"};
String [] registro = new String [3];
totalregistros=0;
modelo = new DefaultTableModel(null, titulos);
sAccess = "select * from tbl_examenes where Nombre like '%" + buscar + "%' order by Id_examen desc";
try{
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery(sAccess);
while(rs.next()){
registro [0] = rs.getString("Id_examen");
registro [1] = rs.getString("Nombre");
registro [2] = rs.getString("Precio");
// NumberFormat numeroFormateado = new DecimalFormat("0.00");
// Double a = Double.parseDouble(rs.getString("Precio"));
// String b = "$"+numeroFormateado.format(a);
// registro [2] = b;
//
totalregistros = totalregistros+1;
modelo.addRow(registro);
}
return modelo;
} catch (Exception e){
JOptionPane.showMessageDialog(null, e);
return null;
}
}
public boolean insertar(vexamenes dts){
sAccess = "insert into tbl_examenes (Nombre, Precio)" +
"values (?,?)" ;
///ahhh
//programa decian seran facil decian xD
try {
PreparedStatement pst = cn.prepareStatement (sAccess);
pst.setString(1, dts.getNombre());
pst.setDouble(2, dts.getPrecio());
int n = pst.executeUpdate();
if (n!=0){
return true;
}
else{
return false;
}
} catch (Exception e) {
JOptionPane.showConfirmDialog(null, e);
return false;
}
}
public boolean editar(vexamenes dts){
sAccess = "update tbl_examenes set Nombre=?,Precio=?"+
" where Id_examen=?";
try {
PreparedStatement pst = cn.prepareStatement (sAccess);
pst.setString(1, dts.getNombre());
pst.setDouble(2, dts.getPrecio());
pst.setInt(3, dts.getId_examen());
int n = pst.executeUpdate();
if (n!=0){
return true;
}
else{
return false;
}
} catch (Exception e) {
JOptionPane.showConfirmDialog(null, e);
return false;
}
}
public boolean eliminar (vexamenes dts){
sAccess = "delete from tbl_examenes where Id_examen=?";
try {
PreparedStatement pst = cn.prepareStatement (sAccess);
pst.setInt(1, dts.getId_examen());
int n = pst.executeUpdate();
if (n!=0){
return true;
}
else{
return false;
}
} catch (Exception e) {
JOptionPane.showConfirmDialog(null, e);
return false;
}
}
}
En el evento guardar:
dts.setPrecio_venta(Double.parseDouble(txtprecio_venta.getText()));