Java examples for java.sql:Table
Adds the user into the database table.
//package com.java2s; import java.sql.SQLException; import java.sql.Statement; public class Main { /**//from w ww. j ava 2 s . c o m * Adds the user into the database. * @param username the use's username * @param password the user's password, MD5 twice * @param type the user's type * @param statement the Statement connected to the database * @return true if the user is added, false if the operation failed */ public static boolean addUser(String username, String password, String type, Statement statement) { try { statement .executeUpdate("INSERT INTO users(userid,encryptedpassword,type)VALUES('" + username + "','" + password + "','" + type + "');"); return true; } catch (SQLException e) { return false; } } }