Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package avo.ob.movie;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- *
- * @author phoenix
- */
- public class DbConnetion {
- static String bd = "TelematicsDev";
- static String user = "postgres";
- static String password = "postgres";
- static String url = "jdbc:postgresql://192.168.15.46/TelematicsDev";
- Connection connetion = null;
- public DbConnetion() {
- try {
- Class.forName("org.postgresql.Driver");
- /*
- driver=org.postgresql.Driver
- username=postgres
- password=postgres
- url=jdbc:postgresql://phoenixtelematics.dyndns.org/TelematicsDev
- url=jdbc:postgresql://192.168.15.46/TelematicsDev
- */
- connetion = DriverManager.getConnection(url, user, password);
- if (connetion != null) {
- System.out.println("Conexion a la BD [" + connetion + "] OK");
- }
- } catch (SQLException ex) {
- System.out.println("Exception ocurrida: " + ex.getMessage());
- } catch (ClassNotFoundException ex) {
- }
- }
- public Connection getConnection() {
- return connetion;
- }
- public void disconect() throws SQLException {
- System.out.println("Cerrando conexion: " + connetion);
- if (connetion != null) {
- connetion.close();
- }
- }
- }
- <h:form>
- <h2>Peliculas</h2>
- <p:inputText class="borderInput ui-lg-4" id="busca" value="" style="width:20%" maxlength="100" placeholder="Buscar Pelicula" onkeypress="alfanumerico(event)"/><br/><br/>
- <p:dataTable var="peliculas" value="#{movieBean.peliculas}">
- <p:column headerText="id_movie">
- <h:outputText value="#{movieBean.movies.id_movie}" />
- </p:column>
- <p:column headerText="movie_name">
- <h:outputText value="#{movieBean.movies.movie_name}" />
- </p:column>
- <p:column headerText="movie_year">
- <h:outputText value="#{movieBean.movies.movie_year}" />
- </p:column>
- </p:dataTable>
- </h:form>
- public List<moviesDTO> getMovies(String nombrePelicula) {
- List<moviesDTO> listaPeliculas = new ArrayList<>();
- ConnectionDB conn = new ConnectionDB();
- List<ParametersSP> parametros = new ArrayList<>();
- parametros.add(new ParametersSP("string", nombrePelicula));
- try {
- ResultSet res = conn.ExecuteFunctionQuery("sp_get_peliculas", parametros);
- while (res.next()) {
- moviesDTO movies = new moviesDTO();
- movies.setId_movie(res.getInt(1));
- System.out.println("Id Pelicula..." + movies.getId_movie());
- movies.setMovie_name(res.getString(2));
- movies.setMovie_year(res.getInt(3));
- listaPeliculas.add(movies);
- }
- } catch (SQLException | IOException ex) {
- Logger.getLogger(MovieDAOImplements.class.getName()).log(Level.SEVERE, null, ex);
- }
- return listaPeliculas;
- }
- ConnectionDB conn = new ConnectionDB();
- List<ParametersSP> parametros = new ArrayList<>();
Add Comment
Please, Sign In to add comment