Sei sulla pagina 1di 6

CUADRO COMPARATIVO:

JAVA VS VISUAL BASIC

Materia:

INGENIERÍA DEL SOFTWARE II

Estudiantes:

WILDER JEFRY GOMEZ RIVERA (1.031.134.887)

JENNY ALEJANDRA MORA HERNÁNDEZ (1.022.333.350)

JOHN STEVE PERALTA TORRES (1.015.425.265)

FUNDACIÓN TECNOLÓGICA COLOMBO GERMANA

INGENIERÍA DE SISTEMAS

BOGOTÁ D.C.

2017
JAVA
Main
package clientes;
import java.util.Scanner;
public class Clientes {
public static void main(String[] args) {
Insertar Ins = new Insertar();
Scanner lector = new Scanner(System.in);
int Sel = 999;
do {
System.out.println("Seleccione una opcion: ");
System.out.println("1. Insertar"
switch(Sel){
case 1:
Ins.Insertar();
break;
}
}while (Sel != 0);
}
}
Conexión a la base de datos
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Conexion {
String usr = "root";
String pwd = "";
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/eurekabank";
Connection con = null;
public Connection Conexion(){
try{
Class.forName(driver);
con= DriverManager.getConnection(url, usr, pwd);
return con;
} catch(Exception ex){
ex.printStackTrace();
return con;
}
}
}
Insertar Datos del Cliente
public class Insertar extends Conexion {
PreparedStatement pstm = null;
ResultSet rs = null;
Scanner x = new Scanner(System.in);
Leer Read = new Leer();
String nombre , id, correo;
int telefono, Sel = 999;
public void Insertar(){
do{
try{
Class.forName(driver);
con = DriverManager.getConnection(url,usr,pwd);
this.con.createStatement();
System.out.println("Complete los siguientes campos:");
System.out.print("Nombre: ");
nombre = x.nextLine();
System.out.print("identificación: ");
id = x.nextLine();
System.out.print("Telefono: ");
telefono = x.nextInt();
x.nextLine();
System.out.print("Correo: ");
correo = x.nextLine();
System.out.println("");
String sql="insert into cliente values (null, '" + nombre + "', '" + id + "', '" + telefono + "',
'"+ correo +"')";
pstm = con.prepareStatement(sql);
pstm.executeUpdate(sql);
Read.Leer();
}
catch(Exception ex){
ex.printStackTrace();
throw new RuntimeException(ex);
}
finally{
try{
if( rs != null ) rs.close();
if( pstm != null) pstm.close();
if( con != null) con.close();
}
catch(Exception ex)
{
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
VISUAL BASIC
Conexión Base de Datos
Module Funciones

Public conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data


Source= E:\BD\Clientes.mdb")
Public cmd As New OleDb.OleDbCommand
Public dr As OleDb.OleDbDataReader
Public Sql As String = ""

Public Sub Conectarse()


Try
conn.Open()
MsgBox("Conexion Exitosa")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Module

Clase Cliente
Public Class Cliente

Private nombre As String


Private identi As String
Private telefono As Integer
Private correo As String

Sub New(ByVal nombre As String, ByVal identi As String, ByVal telefono As


Integer, ByVal correo As String)
Me.nombre = nombre
Me.identi = identi
Me.telefono = telefono
Me.correo = correo
End Sub

Function GetNombre() As String


Return Me.nombre
End Function

Function GetIdenti() As String


Return Me.identi
End Function

Function GetTelefono () As Integer


Return Me.telefono
End Function

Function GetCorreo() As String


Return Me.correo
End Function

Function SetNombre(ByVal Nombre As String) As String


Me.nombre = Nombre
Return Nothing
End Function
Function SetIdenti(ByVal Identi As Integer) As String
Me.identi = Identi
Return Nothing
End Function
Function SetTelefono(ByVal Telefono As Integer) As Integer
Me.telefono = Telefono
Return Nothing
End Function
Function SetCorreo(ByVal Correo As String) As String
Me.correo = Correo
Return Nothing
End Function

Main (Formulario)
Private Sub Binsertar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Binsertar.Click
Dim consecutivo, telefono As Integer
Dim nombre, correo, id As String

nombre = Val(Me.TBinsertarnombre.Text)
id = Val(Me.TBinsertarid.Text)
telefono = Val(Me.TBinsertartelefono.Text)
correo = Me.TBinsertarcorreo.Text

Dim cliente1 As New Consulta(consecutivo, nombre, id, teléfono, correo)

cliente1.Insertar()

End Sub

Comparación Código de línea:


CONCLUSIONES

 Al hacer la comparación al inserta un cliente en los dos lenguajes (Visual


Basic- Java) se evidencia que la cantidad de líneas no varía mucho.

 En Visual Basic se ve una presentación más agradable y es más fácil la


programación y la interpretación del código.

 El manejo de Base de Datos para el correcto funcionamiento de ella misma,


se utiliza adecuadamente en ambos lenguajes.

Potrebbero piacerti anche