From 917e44c66ee99f31b0ac655c56b598d71014652e Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Wed, 6 Mar 2013 18:25:50 +0700 Subject: MessagesQueries.getMessageTagsIDs MessagesQueries visitor_id UserQueries.createUser --- src/com/juick/server/UserQueries.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/com/juick/server/UserQueries.java') 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; -- cgit v1.2.3