Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // JDBC driver name and database URL
- static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:mysql://localhost/jiradb";
- // Database credentials
- static final String USER = "root";
- static final String PASS = "test";
- public String generateReportHtml(ProjectActionSupport projectActionSupport, Map map) throws Exception {
- Connection connection = null;
- Statement statement = null;
- StringBuilder stringBuilder = new StringBuilder();
- try{
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection(DB_URL, USER, PASS);
- statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery("SELECT ID, user_key, lower_user_name FROM app_user;");
- while(resultSet.next()){
- stringBuilder.append(resultSet.getInt("ID") + " ");
- stringBuilder.append(resultSet.getString("user_key") + " ");
- stringBuilder.append(resultSet.getString("lower_user_name") + " ");
- stringBuilder.append("\n");
- }
- }catch(Exception e){
- e.printStackTrace();
- stringBuilder.append(e.getMessage());
- }
- // String name = jdbcTemplate.toString();
- return stringBuilder.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement