samedi 25 février 2017

How to add multiple tags (array) to a single post using jsp and mysql?

I have a problem
Tecno are the tags: java,php,javascript
my Recoge_datos.jsp

String[] tecno=request.getParameterValues("tecno");
try{

java.sql.Connection miConexion=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/proyecto_jsp","root","");
java.sql.Statement miStatement=miConexion.createStatement();

String instruccionSql="INSERT INTO USERS (nombre, apellido, usuario, contra, pais, tecno) VAlUES ('" + nombre + "','" + apellido +"','"+ usuario +"','"+ contra +"','" + pais +"','" + tecno + "')";

miStatement.executeUpdate(instruccionSql);

out.println(" Registrado con exito ");
}catch(Exception e){
out.println("Ha habido un error");
}

and my formulario_registro.html

<form action="Recoge_datos.jsp" method="post">
<tr>
  <td>Tecnologias: </td>
  <td><label>
    <input type="checkbox" name="tecno" value="Java" id="tecnologias_0">
    Java</label>
    <br>
    <label>
      <input type="checkbox" name="tecno" value="PHP" id="tecnologias_1">
      Php</label>
    <br>
    <label>
      <input type="checkbox" name="tecno" value="JavaScript" id="tecnologias_2">
  JavaScript</label></td>
</tr>

In MySQL I have this: [Ljava.lang.String;@6ecf7e94
But it should be java,javascript,php If they were selected
I use the latest version of java and tomcat 9, all the latest version 02/2017




Aucun commentaire:

Enregistrer un commentaire