Example usage for java.sql SQLException toString

List of usage examples for java.sql SQLException toString

Introduction

In this page you can find the example usage for java.sql SQLException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public void deleteDatamap(Datamap datamap) {
    StringBuilder query = new StringBuilder();
    query.append("delete from datamap where `id`=? ");

    Connection connection = this.databaseSpring.connect();
    try {//from w  w w .j a v a  2s.c o m
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, datamap.getId().toString());

            preStat.executeUpdate();

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }
}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public void updateDatamap(String id, String columnName, String value) {
    boolean throwExcep = false;
    StringBuilder query = new StringBuilder();
    query.append("update datamap set `");
    query.append(columnName);//  ww  w.j  av  a 2 s.  c  o m
    query.append("`=? where `id`=? ");

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, value);
            preStat.setString(2, id);

            preStat.executeUpdate();
            throwExcep = false;

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }

}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public void createDatamap(Datamap datamap) {
    StringBuilder query = new StringBuilder();
    query.append(//from  w w w  . ja v a 2s  .c o  m
            "INSERT INTO datamap (`id`,`stream`,`application`,`page`,`locationType`,`locationValue`,`implemented`, `zone`, `picture`, `comment`) ");
    query.append("VALUES (0,?,?,?,?,?,?,?,?,?)");

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, datamap.getStream());
            preStat.setString(2, datamap.getApplication());
            preStat.setString(3, datamap.getPage());
            preStat.setString(4, datamap.getLocationType());
            preStat.setString(5, datamap.getLocationValue());
            preStat.setString(6, datamap.getImplemented());
            preStat.setString(7, datamap.getZone());
            preStat.setString(8, datamap.getPicture());
            preStat.setString(9, datamap.getComment());

            preStat.executeUpdate();

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }

}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public List<Datamap> findAllDatamap() {
    List<Datamap> list = null;
    final String query = "SELECT * FROM datamap";

    Connection connection = this.databaseSpring.connect();
    try {/*from w w  w.ja va2 s.  co  m*/
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            ResultSet resultSet = preStat.executeQuery();
            list = new ArrayList<Datamap>();
            try {
                while (resultSet.next()) {
                    list.add(this.loadDatamapFromResultSet(resultSet));
                }
            } catch (SQLException exception) {
                Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
            } finally {
                resultSet.close();
            }
        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }
    return list;
}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public Datamap findDatamapByKey(String id) {
    Datamap result = null;/*from w  w  w.  j a v a 2s  .c  o  m*/
    final String query = "SELECT * FROM datamap  WHERE id = ?";

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, id);

            ResultSet resultSet = preStat.executeQuery();
            try {
                if (resultSet.first()) {
                    result = loadDatamapFromResultSet(resultSet);
                }
            } catch (SQLException exception) {
                Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
            } finally {
                resultSet.close();
            }
        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }

    return result;
}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public List<Datamap> findDatamapListByColumnValue(String column, String value) {
    List<Datamap> result = new ArrayList<Datamap>();

    StringBuilder query = new StringBuilder();
    query.append("SELECT * FROM datamap where `");
    query.append(column);/*from   w  w  w.  j  av  a2s .c o  m*/
    query.append("` = ?");

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, value);
            ResultSet resultSet = preStat.executeQuery();
            try {
                while (resultSet.next()) {
                    result.add(this.loadDatamapFromResultSet(resultSet));
                }

                resultSet.close();
            } catch (SQLException exception) {
                Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
            } finally {
                resultSet.close();
            }

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }

    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }
    return result;
}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public boolean allImplementedByCriteria(String column, String value) {
    StringBuilder query = new StringBuilder();
    query.append("SELECT count(*) as val FROM datamap where `");
    query.append(column);//from  w w w . j ava  2s  . c  om
    query.append("` = ? and implemented!='Y'");

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, value);
            ResultSet resultSet = preStat.executeQuery();
            try {
                if (resultSet.next()) {
                    if (resultSet.getString("val").equals("0")) {
                        return true;
                    }

                }

                resultSet.close();
            } catch (SQLException exception) {
                Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
            } finally {
                resultSet.close();
            }

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }

    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }
    return false;
}

From source file:com.redoute.datamap.dao.impl.DatamapDAO.java

@Override
public List<String> findDistinctValuesfromColumn(String colName) {
    List<String> result = new ArrayList<String>();

    StringBuilder query = new StringBuilder();
    query.append("SELECT distinct ");
    query.append(colName);//from  w w w  .ja  va2 s. c o  m
    query.append(" FROM datamap order by ");
    query.append(colName);
    query.append(" asc");

    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            ResultSet resultSet = preStat.executeQuery();
            try {

                while (resultSet.next()) {
                    result.add(resultSet.getString(1) == null ? "" : resultSet.getString(1));
                }

                resultSet.close();
            } catch (SQLException exception) {
                Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
            } finally {
                resultSet.close();
            }

        } catch (SQLException exception) {
            Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
        } finally {
            preStat.close();
        }

    } catch (SQLException exception) {
        Logger.log(DatamapDAO.class.getName(), Level.ERROR, exception.toString());
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            Logger.log(DatamapDAO.class.getName(), Level.WARN, e.toString());
        }
    }
    return result;
}

From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java

@Test
public void ResultSetMetadata() {
    try {/*from   w ww. ja va2s . com*/
        this.logger.debug(BQScrollableResultSetFunctionTest.Result.getMetaData().getSchemaName(1));
        this.logger.debug(BQScrollableResultSetFunctionTest.Result.getMetaData().getScale(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
    }
    Assert.assertTrue(true);
}

From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java

@Test
public void TestResultSetFirst() {
    try {/*from ww  w  . j a  v  a2  s.  c o  m*/
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.first());
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.isFirst());
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }
}