aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/UserQueries.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/juick/server/UserQueries.java')
-rw-r--r--src/com/juick/server/UserQueries.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java
index ff1d0e24..17873676 100644
--- a/src/com/juick/server/UserQueries.java
+++ b/src/com/juick/server/UserQueries.java
@@ -21,6 +21,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
@@ -32,6 +33,29 @@ public class UserQueries {
static final String ABCDEF = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ public static int createUser(Connection sql, String username, String password, String lang) {
+ int uid = 0;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("INSERT INTO users(nick,passw,lang) VALUES (?,?,?)", Statement.RETURN_GENERATED_KEYS);
+ stmt.setString(1, username);
+ stmt.setString(2, password);
+ stmt.setString(3, lang);
+ stmt.executeUpdate();
+ rs = stmt.getGeneratedKeys();
+ if (rs.first()) {
+ uid = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return uid;
+ }
+
public static com.juick.User getUserByNick(Connection sql, String username) {
com.juick.User user = null;