You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

I want to use Beanshell plugins and SQL join queries  to return the name of user(s) for mapping participants. 
It doesn't seem to work. How do I go about doing this 

SELECT username FROM dir_user WHERE criteria = 'something';

Connection con = null;
    try { Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
        if(!con.isClosed()){
            //manually handle insert and update by checking the data is exist or not
            String selectQuery = "SELECT `id` FROM dir_user WHERE `id`=?";
            PreparedStatement stmt = con.prepareStatement(selectQuery);
            stmt.setString(1, id);
            ResultSet rs = stmt.executeQuery();

...
Connection con = null;
    try {
	Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "London2012");

        if(!con.isClosed()){
            //manually handle insert and update by checking the data is exist or not
            String selectQuery = "SELECT `id` FROM dir_user WHERE `id`=?";
            PreparedStatement stmt = con.prepareStatement(selectQuery);
            stmt.setString(1, id);
            ResultSet rs = stmt.executeQuery();
    } catch (Exception ex) {
        System.err.println("#### Exception: " + ex.getMessage());
    } finally {
        try {
            if(con != null)
                con.close();
        } catch(SQLException e) {}
    }
return rs;
...
  • No labels