Package com.mysql.jdbc

Examples of com.mysql.jdbc.Connection


    @Test
    public void preProcessShouldBeginTracingSQLCall() throws Exception {
        final String sql = randomAlphanumeric(20);
        final String schema = randomAlphanumeric(20);

        final Connection connection = mock(Connection.class);
        when(connection.getSchema()).thenReturn(schema);

        assertNull(subject.preProcess(sql, mock(Statement.class), connection));

        final InOrder order = inOrder(clientTracer);
View Full Code Here


        final String sql = randomAlphanumeric(20);
        final String schema = randomAlphanumeric(20);

        final PreparedStatement statement = mock(PreparedStatement.class);
        when(statement.getPreparedSql()).thenReturn(sql);
        final Connection connection = mock(Connection.class);
        when(connection.getSchema()).thenReturn(schema);

        assertNull(subject.preProcess(null, statement, connection));

        final InOrder order = inOrder(clientTracer);
View Full Code Here

  }

  @Override
  public int update(Entidad bean, String condicion) throws SQLException {
    Cuenta cta = (Cuenta) bean;
    Connection con;
    try {
      con = JDBCConnection.getConexion();
      String sqlStm = "update cuenta set saldo = " + cta.getSaldo()
          + " where idCuenta = " + cta.getIdCuenta();
      java.sql.Statement sqlSta = con.createStatement();
      sqlSta.executeUpdate(sqlStm);

      // si la cuenta tiene movimientos nuevos los ingresa tambien a la
      // base de datos
View Full Code Here

   * @return
   * @throws SQLException
   */
  @Override
  public Entidad find(int codigo) throws SQLException {
    Connection con;
    try {
      con = JDBCConnection.getConexion();
      String orden = "SELECT * FROM cuenta c " + "WHERE c.idCuenta = "
          + codigo;
      java.sql.Statement sentencia = con.createStatement();
      ResultSet rs = sentencia.executeQuery(orden);
      System.out.println("ejecuto query de cuenta");
      Cuenta cuenta = null;
      int idCliente = -1;
      while (rs.next()) {
View Full Code Here

  }

  private void insertarMovimiento(Cuenta cta, MvtosCuenta mc)
      throws SQLException {
    try {
      Connection con = JDBCConnection.getConexion();
      String orden = "INSERT INTO movimientoscuenta"
          + " (Cuenta_idCuenta, tipoMovimiento, valorMovimiento, fechaMovimiento) VALUES ("
          + +cta.getIdCuenta() + ", " + mc.getTipoMvto() + ", "
          + mc.getValorMvto() + ",'" + mc.getFechaMvto() + "')";
      System.out.println("comando para ejecutar " + orden);
      java.sql.Statement sentencia = con.createStatement();
      int numFilas = sentencia.executeUpdate(orden);
      sentencia.close();
    } catch (Exception ex) {
      Logger.getLogger(CuentaDAO.class.getName()).log(Level.SEVERE, null,
          ex);
View Full Code Here

  }

  @Override
  public int update(Entidad bean, String condicion) throws SQLException {
    Cuenta cta = (Cuenta) bean;
    Connection con;
    try {
      con = JDBCConnection.getConexion();
      String sqlStm = "update cuenta set saldo = " + cta.getSaldo()
          + " where idCuenta = " + cta.getIdCuenta();
      java.sql.Statement sqlSta = con.createStatement();
      sqlSta.executeUpdate(sqlStm);

      // si la cuenta tiene movimientos nuevos los ingresa tambien a la
      // base de datos
View Full Code Here

   * @return
   * @throws SQLException
   */
  @Override
  public Entidad find(int codigo) throws SQLException {
    Connection con;
    try {
      con = JDBCConnection.getConexion();
      String orden = "SELECT * FROM cuenta c " + "WHERE c.idCuenta = "
          + codigo;
      java.sql.Statement sentencia = con.createStatement();
      ResultSet rs = sentencia.executeQuery(orden);
      System.out.println("ejecuto query de cuenta");
      Cuenta cuenta = null;
      int idCliente = -1;
      while (rs.next()) {
View Full Code Here

  }

  private void insertarMovimiento(Cuenta cta, MvtosCuenta mc)
      throws SQLException {
    try {
      Connection con = JDBCConnection.getConexion();
      String orden = "INSERT INTO movimientoscuenta"
          + " (Cuenta_idCuenta, tipoMovimiento, valorMovimiento, fechaMovimiento) VALUES ("
          + +cta.getIdCuenta() + ", " + mc.getTipoMvto() + ", "
          + mc.getValorMvto() + ",'" + mc.getFechaMvto() + "')";
      System.out.println("comando para ejecutar " + orden);
      java.sql.Statement sentencia = con.createStatement();
      int numFilas = sentencia.executeUpdate(orden);
      sentencia.close();
    } catch (Exception ex) {
      Logger.getLogger(CuentaDAO.class.getName()).log(Level.SEVERE, null,
          ex);
View Full Code Here

  }

  @Override
  public Entidad find(int codigo) throws SQLException {
    try {
      Connection con = JDBCConnection.getConexion();
      // // Si la condición es null o vacia, no hay parte WHERE
      String orden = "SELECT * FROM cliente cl "
          + "WHERE cl.idcliente = " + codigo;
      java.sql.Statement sentencia = con.createStatement();
      ResultSet rs = sentencia.executeQuery(orden);
      Cliente cliente = null;
      while (rs.next()) {
        cliente = new Cliente();
        cliente.setIdCliente(rs.getInt("idcliente"));
View Full Code Here

  }
 
  private static Connection getConnection(String url) throws Exception {
    Class.forName("com.mysql.jdbc.Driver");

    Connection conn = (Connection) DriverManager
        .getConnection(url);
    return conn;
  }
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.