aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/UserQueries.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-03-06 18:25:50 +0700
committerGravatar Ugnich Anton2013-03-06 18:25:50 +0700
commit917e44c66ee99f31b0ac655c56b598d71014652e (patch)
treec1407079873bdcb9a37427ac8bf29d6a3da72ff7 /src/com/juick/server/UserQueries.java
parentb74e6c267498e6fda56a5167346623bf55a8f01e (diff)
MessagesQueries.getMessageTagsIDs
MessagesQueries visitor_id UserQueries.createUser
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;