Advertisement
Brandford

Pool JDBC FileMaker

Aug 16th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. package javaapplication5;
  2.  
  3. import java.sql.*;
  4.  
  5. public class prueba {
  6.  
  7.     // Declaración de la clase JDBC del driver fmjdbc.jar
  8.     static final String JDBC_DRIVER = "com.filemaker.jdbc.Driver";
  9.     // Declaración de la URL del Servidor FileMaker
  10.     static final String DB_URL = "jdbc:filemaker://175.0.0.228/BasedeDatos";
  11.     // Credenciales de conexión a la Base de Datos FileMaker
  12.     static final String USER = "vmorales";
  13.     static final String PASS = "pass";
  14.  
  15.     public static void main(String[] args) {
  16.         Connection conn = null;
  17.         Statement stmt = null;
  18.         try {
  19.             // Carga de la clase JDBC del driver fmjdbc.jar
  20.             Class.forName("com.filemaker.jdbc.Driver");
  21.  
  22.             System.out.println("Conectamos a la base de datos.");
  23.             conn = DriverManager.getConnection(DB_URL, USER, PASS);
  24.  
  25.             System.out.println("Creamos la consulta");
  26.             stmt = conn.createStatement();
  27.             String sql;
  28.             sql = "SELECT * FROM INSUMOS WHERE STOCK_BODEGA < 5";
  29.  
  30.             ResultSet rs = stmt.executeQuery(sql);
  31.             int i = 0;
  32.            
  33.             while (rs.next()) {
  34.                 i++;
  35.                 System.out.println(i + " REGISTRO");
  36.                
  37.             }
  38.             rs.close();
  39.             stmt.close();
  40.             conn.close();
  41.         } catch (SQLException se) {
  42.             se.printStackTrace();
  43.         } catch (Exception e) {
  44.             e.printStackTrace();
  45.         } finally {
  46.             try {
  47.                 if (stmt != null) {
  48.                     stmt.close();
  49.                 }
  50.             } catch (SQLException sqlexcepcion) {
  51.             }
  52.             try {
  53.                 if (conn != null) {
  54.                     conn.close();
  55.                 }
  56.             } catch (SQLException se) {
  57.                 se.printStackTrace();
  58.             }
  59.         }
  60.         System.out.println("FIN");
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement