Basically schedule a view in which I could enter data, modify, elminate, so that if I clicked on the table it would let me modify the data that I want, the problem is that it throws me an error that I do not understand and this does not let me move on.
I enclose the error:
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: 10 at java.lang.String.substring (String.java:1963) at Sistema.Arriendobiblioteca.jTable1MouseClicked (Arriendobiblioteca.java:981) at Sistema.Arriendobiblioteca.access $ 400 (Arriendobiblioteca.java:16) at Sistema.Arriendobiblioteca $ 5.mouseClicked (Arriendobiblioteca.java:177) at java.awt.AWTEventMulticaster.mouseClicked (AWTEventMulticaster.java:270)
I go to line 981 of my code that is according to the netbeans that is causing this problem.
I will attach that part of the code so that you can understand me:
private void tbuscarKeyReleased(java.awt.event.KeyEvent evt) {
String campo = this.tbuscar.getText();
try {
ConexionBD nuevos = new ConexionBD();
Statement st = nuevos.conn.createStatement();
String comando ="select count(*) from arriendo "
+ "inner join libros on arriendo.Libros_idLibros=libros.idLibros"
+ " where Libros_arriendo like '" + campo + "%'"
+ " or titulo_libro like '%" + campo + "%'"
+ " or Fecha_arriendo like '" + campo + "%'"
+ " or Fecha_devolucion like '%" + campo + "%'"
+ " or Fecha_entrega like '" + campo + "%'"
+ " or Costo_arriendo like '%" + campo + "%'"
+ " order by idArriendo asc";
ResultSet rs = st.executeQuery(comando);
this.jTable1.setModel(nuevos.consultaArriendo(campo));
} catch (Exception e) {
}
}
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
int seleccion = jTable1.rowAtPoint(evt.getPoint());
tcosto.setText(String.valueOf(jTable1.getValueAt(seleccion, 5)));
nomArriendo.setText(String.valueOf(jTable1.getValueAt(seleccion, 0)));
String fechaArridia, fechaArrimes, fechaArrian;
String fechaEntdia, fechaEntmes, fechaEntan;
String fechaDevdia, fechaDevmes, fechaDevan;
fechaArrimes = String.valueOf(jTable1.getValueAt(seleccion, 1)).substring(3, 5);
boxmes.setSelectedItem(fechaArrimes);
fechaArridia = String.valueOf(jTable1.getValueAt(seleccion, 1)).substring(0, 2);
boxdia.setSelectedItem(fechaArridia);
fechaArrian = String.valueOf(jTable1.getValueAt(seleccion, 1)).substring(6, 10);
boxan.setSelectedItem(fechaArrian);
fechaEntmes = String.valueOf(jTable1.getValueAt(seleccion, 4)).substring(14, 16);
boxenmes.setSelectedItem(fechaEntmes);
fechaEntdia = String.valueOf(jTable1.getValueAt(seleccion, 4)).substring(11, 13);
boxendia.setSelectedItem(fechaEntdia);
fechaEntan = String.valueOf(jTable1.getValueAt(seleccion, 4)).substring(17, 21);
boxenan.setSelectedItem(fechaEntan);
fechaDevmes = String.valueOf(jTable1.getValueAt(seleccion, 6)).substring(25, 27);
boxdevmes.setSelectedItem(fechaDevmes);
fechaDevdia = String.valueOf(jTable1.getValueAt(seleccion, 6)).substring(22, 24);
boxdevdia.setSelectedItem(fechaDevdia);
fechaDevan = String.valueOf(jTable1.getValueAt(seleccion, 6)).substring(28, 32);
boxdevan.setSelectedItem(fechaDevan);
combolibro.setSelectedItem(String.valueOf(jTable1.getValueAt(seleccion, 3)));
try {
ConexionBD nuevos = new ConexionBD();
Statement st = nuevos.conn.createStatement();
String comando = "Select * from libros";
ResultSet rs = st.executeQuery(comando);
while (rs.next()) {
combolibro.setSelectedItem(rs.getString("idLibros") + " " + String.valueOf(jTable1.getValueAt(seleccion, 2)));
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
this.bcrear.setEnabled(false);
this.bmodificar.setEnabled(true);
this.beliminar.setEnabled(true); // TODO add your handling code here:
}
The "box ..." that is the name that the buttons of my views receive, I have 3 different dates with different names.