Merge pull request 'DB' (#6) from DB into master

Reviewed-on: http://poopki.duckdns.org:3000/poopki/User_Management_Base_Code/pulls/6
Status
poopki 3 years ago
commit eb0b59bbab
  1. 9
      DB/DBUpdate.java

@ -32,7 +32,7 @@ public class DBUpdate {
stmt = conn.createStatement(); stmt = conn.createStatement();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String sql = sb.append("create table if not exists UserInfo(") String sql = sb.append("create table if not exists UserInfo(")
.append("UUID varchar(36),") .append("UUID varchar(36) PRIMARY KEY,")
.append("Nation int(8),") //public .append("Nation int(8),") //public
.append("Squad int(8),") //public .append("Squad int(8),") //public
.append("Farm int(8)") //public .append("Farm int(8)") //public
@ -90,6 +90,7 @@ public class DBUpdate {
} }
} }
public void UpdateDB() throws SQLException { public void UpdateDB() throws SQLException {
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -102,13 +103,13 @@ public class DBUpdate {
//sql = sb.append("insert into UserInfo values('"+key+"',"+0+","+0+","+0+","+0+","+0+")").toString(); //sql = sb.append("insert into UserInfo values('"+key+"',"+0+","+0+","+0+","+0+","+0+")").toString();
//String sql = sb.append("insert into UserInfo values ('test', 0)").toString(); //String sql = sb.append("insert into UserInfo values ('test', 0)").toString();
//stmt.execute(sql); //stmt.execute(sql);
String sql = "INSERT INTO UserInfo VALUES (?,?,?,?)"; String sql = "REPLACE INTO UserInfo VALUES (?,?,?,?)";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
//pstmt.setString(1, key.toString()); //pstmt.setString(1, key.toString());
pstmt.setString(1, String.valueOf(m_InfoArrayInstance.m_UserInfoArray.get(key).getUserUUID())); pstmt.setString(1, String.valueOf(m_InfoArrayInstance.m_UserInfoArray.get(key).getUserUUID()));
pstmt.setString(2, String.valueOf(11)); pstmt.setString(2, String.valueOf(11));
pstmt.setString(3, String.valueOf(12)); pstmt.setString(3, String.valueOf(23));
pstmt.setString(4, String.valueOf(33)); pstmt.setString(4, String.valueOf(56));
int cnt = pstmt.executeUpdate(); int cnt = pstmt.executeUpdate();
if( cnt == 0 ){ if( cnt == 0 ){

Loading…
Cancel
Save