daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Jun 5th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Proyecto;
  2.  
  3.    import java.net.*;
  4.    import java.io.*;
  5.    import java.sql.*;
  6.  
  7.     class servidor {
  8.  
  9.       static Connection canal = null;
  10.       static Statement instruccion=null;
  11.       static ResultSet rs;
  12.  
  13.       static String tt1;
  14.       static String tt2;
  15.       static String libro ;
  16.       static String s;
  17.       static String respuesta;
  18.  
  19.       static int Contador=0;
  20.        public static void main (String[] args) throws IOException, SQLException {
  21.  
  22.  
  23.          System.out.println("Servidor funcionando");
  24.          ServerSocket servSocket = new ServerSocket(9001);
  25.          while (true) {
  26.             Socket socket = servSocket.accept();
  27.             OutputStream salida = socket.getOutputStream();
  28.             DataOutputStream salidaDatos = new DataOutputStream(salida);
  29.             InputStream entrada = socket.getInputStream();
  30.             DataInputStream entradaDatos = new DataInputStream(entrada);
  31.  
  32.             tt1=entradaDatos.readUTF();
  33.             System.out.println("*"+tt1+"*");
  34.             try {
  35.  
  36.             Class.forName("com.mysql.jdbc.Driver");
  37.             canal = DriverManager.getConnection("jdbc:mysql://localhost:3306/movil", "root", "silvana");
  38.            // String tt1= "TALA";
  39.             instruccion = canal.createStatement();
  40.             //System.out.println("antes del selec");
  41.             ResultSet rs = instruccion.executeQuery(
  42.                     "select * from libro where libro.libro= '"+tt1+"'");
  43.             // System.out.println("despues del selec");
  44.             while (rs.next()) {
  45.                 tt2=(rs.getString(1) + " " + rs.getString(2)
  46.                         + " " + rs.getString(3)+"   "+rs.getString(4));
  47.                 System.out.println(""+tt2);
  48.                
  49.             }
  50.         } catch (Exception e) {
  51.             e.printStackTrace();
  52.         }
  53.          salidaDatos.writeUTF(tt2);
  54.  
  55.             }
  56.  
  57.    }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top