Advertisement
JVFabia

JDBC Clase 6

Oct 5th, 2020
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package org.forge;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.         // nombre = Juan Perez
  10.         // rut=  25.542.569-8
  11.         // user = jperez
  12.         // password = P25.54
  13.         // url = forgedb.netbyteoss.com
  14.         // puerto = 5443
  15.         // base de datos = forge_alumnos
  16.         try {
  17.  
  18.  
  19.             try {
  20.                 Class.forName("org.postgresql.Driver");
  21.             } catch (ClassNotFoundException ex) {
  22.                 System.out.println("Error, el driver de PostgresSQL no se ha cargado : " + ex);
  23.             }
  24.  
  25.             Connection conn = null;
  26.             // Conectamos con la base de datos
  27.             conn = DriverManager.getConnection(
  28.                     "jdbc:postgresql://forgedb.netbyteoss.com:5443/forge_alumnos",
  29.                     "jperez", "P25.54"
  30.             );
  31.         } catch (java.sql.SQLException sqle) {
  32.             System.out.println("Error:" + sqle);
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement