








Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!









-- MySQL Workbench Forward Engineering
-- Table mydb.Cuenta
CREATE TABLE IF NOT EXISTS mydb.Cuenta ( NRO DE CUENTA INT NOT NULL AUTO_INCREMENT, NOMBRE DE CUENTA VARCHAR(45) NOT NULL, NOMBRE SUCURSAL VARCHAR(45) NOT NULL, SALDO DISPONIBLE INT NOT NULL, SALDO TOTAL VARCHAR(45) NOT NULL, PRIMARY KEY (NRO DE CUENTA)) ENGINE = InnoDB;
-- Table mydb.Cliente
CREATE TABLE IF NOT EXISTS mydb.Cliente ( CEDULA INT NOT NULL AUTO_INCREMENT, NOMBRE VARCHAR(45) NOT NULL, APELLIDO VARCHAR(45) NOT NULL, CIUDAD VARCHAR(45) NOT NULL, NRO DE CUENTA INT NOT NULL, PAIS VARCHAR(45) NOT NULL, CORREO VARCHAR(45) NOT NULL, PRIMARY KEY (CEDULA), INDEX NRO DE CUENTA_idx (NRO DE CUENTA ASC) VISIBLE,
NRO DE CUENTANRO DE CUENTA)REFERENCES mydb.Transaccciones (idTransaccciones) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT NRO DE CUENTA FOREIGN KEY (NRO DE CUENTA) REFERENCES mydb.Cuenta (NRO DE CUENTA) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB;
-- Table mydb.Banco
CREATE TABLE IF NOT EXISTS mydb.Banco ( idBanco INT NOT NULL, NOMBRE DEL BANCO VARCHAR(45) NOT NULL, NIT VARCHAR(45) NOT NULL, PRIMARY KEY (idBanco)) ENGINE = InnoDB;
-- Table mydb.Sucursal
CREATE TABLE IF NOT EXISTS mydb.Sucursal (
Conexión entre bases de datos y mysql import java.sql.DriverManager; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class PruebaMySQL { public static void main(String[] args) { Connection con = null; try { Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/sakila?serverTimezone=UTC ", "root", "jhmb100352JH"); System.out.println("Connection OK"); }catch (Exception e) { System.err.println(e); } } } package clientSocket import java.net.*;
import java.io.*; public class Ncliente { // 1 iniciamos los flujos de entrada y salida en el Socket privado ; private DataInputStream input = null; private DataInputStream inputServer = null; private DataOutputStream out = null; private String information = ""; // 2. Colocamso la información de ip y puerto public Ncliente(String ip, puerto ) { // Establecemos conexión try { socket = new Socket(address, port); System.out.println("Connected"); // Entrada ala terminal input = new DataInputStream(System.in); // entrada al servidor inputServer = new DataInputStream(socket.getInputStream()); // se envía la salida al socket out = new DataOutputStream(socket.getOutputStream()); // se imprime el mensaje en pantalla del servidor } catch(UnknownHostException u) {
System.out.println(i); } } public static void main(String[] args) { // TODO Auto-generated method stub Ncliente cliente = new Ncliente("186.86.32.212", 5000); } } Servidor package Sockets; import java.net.; import java.io.; import java.util.Scanner; public class Servidor { static int PUERTO = 5000; // aquí definimos el puerto ServerSocket sc; Socket so; DataOutputStream salida; // bufer para armar las salidas o lo que debe responder DataInputStream entrada; // bufer para recibir datos String mensajeRecibido; // Variable donde guardo lo que llega public void initServidor() { Scanner teclado = new Scanner(System.in); try { sc = new ServerSocket(5000); //arbrir el puerto
so = new Socket(); System.out.println("Esperando conexión..."); so = sc.accept(); System.out.println("Se conecto un cliente..."); entrada = new DataInputStream(so.getInputStream()); //armar el constructor de recibo salida = new DataOutputStream(so.getOutputStream()); String msn = ""; while (!msn.equals("x")) { mensajeRecibido = entrada.readUTF();// Leemos lo que llega System.out.println(mensajeRecibido); System.out.println("responder al cliente --> escriba algo"); msn = teclado.nextLine(); salida.writeUTF("" + msn);// enviamos mensaje } // sc.close(); } catch (Exception e) { } } public static void main(String[] args) { Servidor o = new Servidor(); o.initServidor(); }