Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package control;
- import java.sql.Statement;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- /**
- *
- * @author Laboratorio
- */
- public class ManejadorBaseDeDatos {
- private Connection conexion;
- private Statement instruccionSql;
- private ResultSet resultado;
- private ArrayList<String> lista;
- public ManejadorBaseDeDatos() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost/bd_peliculas";
- conexion = java.sql.DriverManager.getConnection(url, "root", "root");
- instruccionSql = conexion.createStatement();
- } catch (ClassNotFoundException | SQLException ex) {
- }
- }
- public ArrayList<String> obtenerPeliculas() {
- try {
- resultado = instruccionSql.executeQuery("SELECT id_pelicula, titulo, FROM peliculas");
- while (resultado.next()) {
- lista.add(resultado.getString("titulo"));
- }
- return lista;
- } catch (SQLException ex) {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement