Пример #1
0
 public User userAuthentication(String username, String pass) {
   User user = null;
   String sql =
       "select id,username,pass from deri.dba.users where username='******' and pass='******'";
   try {
     conn = ConnectionPool.getConnectionPool().getConnection();
     Statement st = conn.createStatement();
     if (st.execute(sql)) {
       ResultSet rs = st.getResultSet();
       while (rs.next()) {
         user = new User();
         user.setId("http://lsm.deri.ie/resource/" + rs.getString("id"));
         user.setPass(pass);
       }
       ConnectionPool.attemptClose(rs);
     }
     ConnectionPool.attemptClose(st);
     ConnectionPool.attemptClose(conn);
   } catch (Exception e) {
     e.printStackTrace();
     ConnectionPool.attemptClose(conn);
   }
   return user;
 }
Пример #2
0
 public User getUserWithUserId(String userId) {
   // TODO Auto-generated method stub
   User user = null;
   userId = "<" + userId + ">";
   String sql =
       "sparql select ?nickname ?pass ?username "
           + "where{ "
           + userId
           + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://lsm.deri.ie/ont/lsm.owl#User>."
           + userId
           + " <http://lsm.deri.ie/ont/lsm.owl#hasUserName> ?username."
           + userId
           + " <http://lsm.deri.ie/ont/lsm.owl#hasNickName> ?nickname."
           + userId
           + " <http://lsm.deri.ie/ont/lsm.owl#hasPassword> ?pass."
           + "}";
   try {
     conn = ConnectionPool.getConnectionPool().getConnection();
     Statement st = conn.createStatement();
     if (st.execute(sql)) {
       ResultSet rs = st.getResultSet();
       while (rs.next()) {
         user = new User();
         user.setId(rs.getString(userId));
         user.setNickname(rs.getString("nickname"));
         user.setUsername(rs.getString("username"));
         user.setPass(rs.getString("pass"));
       }
       ConnectionPool.attemptClose(rs);
     }
     ConnectionPool.attemptClose(st);
     ConnectionPool.attemptClose(conn);
   } catch (Exception e) {
     e.printStackTrace();
     ConnectionPool.attemptClose(conn);
   }
   return user;
 }