Advertisement
Guest User

db

a guest
Jan 15th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.74 KB | None | 0 0
  1. package sql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.util.ArrayList;
  9.  
  10. import fileManagement.IniFileReader;
  11. import rankingSystem.Rank;
  12.  
  13. public class RankingDB {
  14.  
  15. private static int userlist_id = 0;
  16. private static long user_id = 0;
  17. private static long fk_guild_id = 0;
  18. private static int level = 0;
  19. private static int currentExperience = 0;
  20. private static int rankUpExperience = 0;
  21. private static long experience = 0;
  22. private static long currency = 0;
  23.  
  24. private static long guild_id = 0;
  25. private static int fk_rankingSystem = 0;
  26. private static long [] role = new long [10];
  27.  
  28. private static int rankingSystem = 0;
  29. private static int maxRank = 0;
  30. private static int roleAssignLevel = 0;
  31. private static String description = null;
  32.  
  33. private static int numberOfRankingSystems = 0;
  34.  
  35. private static ArrayList<Rank> ranking = new ArrayList<Rank>();
  36.  
  37. private static String username = IniFileReader.getSQLUsername2();
  38. private static String password = IniFileReader.getSQLPassword2();
  39.  
  40. public static void SQLconnection(){
  41. try {
  42. Class.forName("com.mysql.jdbc.Driver");
  43. } catch (ClassNotFoundException e) {
  44. e.printStackTrace();
  45. }
  46. }
  47.  
  48. //UserList table
  49. public static void SQLgetUserList(long _user_id, long _guild_id){
  50. Connection myConn = null;
  51. PreparedStatement stmt = null;
  52. ResultSet rs = null;
  53. try {
  54. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  55. String sql = ("SELECT * FROM UserList WHERE User_ID = ? && FKGuild_ID = ?");
  56. stmt = myConn.prepareStatement(sql);
  57. stmt.setLong(1, _user_id);
  58. stmt.setLong(2, _guild_id);
  59. rs = stmt.executeQuery();
  60. if(rs.next()){
  61. setUserList_id(rs.getInt(1));
  62. setUser_id(rs.getLong(2));
  63. setFK_Guild_id(rs.getLong(3));
  64. setLevel(rs.getInt(4));
  65. setCurrentExperience(rs.getInt(5));
  66. setRankUpExperience(rs.getInt(6));
  67. setExperience(rs.getLong(7));
  68. setCurrency(rs.getLong(8));
  69. }
  70. } catch (SQLException e) {
  71. e.printStackTrace();
  72. } finally {
  73. try { rs.close(); } catch (Exception e) { /* ignored */ }
  74. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  75. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  76. }
  77. }
  78.  
  79. public static void SQLfillUserList(long _user_id, long _fk_guild_id, int _level, int _currentExperience, int _rankUpExperience, long _experience, long _currency){
  80. Connection myConn = null;
  81. PreparedStatement stmt = null;
  82. try {
  83. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  84. String sql = ("INSERT INTO UserList (UserList_ID, User_ID, FKGuild_ID, Level, CurrentExperience, RankUpExperience, Experience, currency, flag) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, 0)");
  85. stmt = myConn.prepareStatement(sql);
  86. stmt.setLong(1, _user_id);
  87. stmt.setLong(2, _fk_guild_id);
  88. stmt.setInt(3, _level);
  89. stmt.setInt(4, _currentExperience);
  90. stmt.setInt(5, _rankUpExperience);
  91. stmt.setLong(6, _experience);
  92. stmt.setLong(7, _currency);
  93. stmt.executeUpdate();
  94. } catch (SQLException e) {
  95. e.printStackTrace();
  96. } finally {
  97. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  98. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  99. }
  100. }
  101.  
  102. public static void SQLsetLevelUp(long _user_id, long _fk_guild_id, int _level, int _currentExperience, int _rankUpExperience, long _experience, long _currency){
  103. Connection myConn = null;
  104. PreparedStatement stmt = null;
  105. try {
  106. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  107. String sql = ("UPDATE UserList SET Level = ?, CurrentExperience = ?, RankUpExperience = ?, Experience = ?, currency = ? WHERE User_ID = ? && FKGuild_ID = ?");
  108. stmt = myConn.prepareStatement(sql);
  109. stmt.setInt(1, _level);
  110. stmt.setInt(2, _currentExperience);
  111. stmt.setInt(3, _rankUpExperience);
  112. stmt.setLong(4, _experience);
  113. stmt.setLong(5, _currency);
  114. stmt.setLong(6, _user_id);
  115. stmt.setLong(7, _fk_guild_id);
  116. stmt.executeUpdate();
  117. } catch (SQLException e) {
  118. e.printStackTrace();
  119. } finally {
  120. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  121. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  122. }
  123. }
  124.  
  125. public static void SQLupdateExperience(long _user_id, long _fk_guild_id, int _currentExperience, long _experience){
  126. Connection myConn = null;
  127. PreparedStatement stmt = null;
  128. try {
  129. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  130. String sql = ("UPDATE UserList SET Experience = ?, CurrentExperience = ? WHERE User_ID = ? && FKGuild_ID = ?");
  131. stmt = myConn.prepareStatement(sql);
  132. stmt.setLong(1, _experience);
  133. stmt.setInt(2, _currentExperience);
  134. stmt.setLong(3, _user_id);
  135. stmt.setLong(4, _fk_guild_id);
  136. stmt.executeUpdate();
  137. } catch (SQLException e) {
  138. e.printStackTrace();
  139. } finally {
  140. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  141. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  142. }
  143. }
  144.  
  145. public static void SQLRanking(){
  146. Connection myConn = null;
  147. PreparedStatement stmt = null;
  148. ResultSet rs = null;
  149. try {
  150. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  151. String sql = ("SELECT `User_ID`, `Level`, `Experience`, @curRank := @curRank + 1 AS Rank FROM `UserList`, (SELECT @curRank := 0) r WHERE FKGuild_id = 296264651057135617 && flag = 0 ORDER BY `Experience` DESC");
  152. stmt = myConn.prepareStatement(sql);
  153. rs = stmt.executeQuery();
  154. while(rs.next()){
  155. Rank rank = new Rank();
  156. rank.setMember_id(rs.getLong(1));
  157. rank.setLevel(rs.getInt(2));
  158. rank.setExperience(rs.getLong(3));
  159. rank.setRank(rs.getInt(4));
  160. ranking.add(rank);
  161. }
  162. } catch (SQLException e) {
  163. e.printStackTrace();
  164. } finally {
  165. try { rs.close(); } catch (Exception e) { /* ignored */ }
  166. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  167. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  168. }
  169. }
  170.  
  171. public static void SQLTopRanking(){
  172. Connection myConn = null;
  173. PreparedStatement stmt = null;
  174. ResultSet rs = null;
  175. try {
  176. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  177. String sql = ("SELECT `User_ID`, `Level`, `Experience`, @curRank := @curRank + 1 AS Rank FROM `UserList`, (SELECT @curRank := 0) r WHERE FKGuild_id = 296264651057135617 && flag = 0 ORDER BY `Experience` DESC LIMIT 10");
  178. stmt = myConn.prepareStatement(sql);
  179. rs = stmt.executeQuery();
  180. while(rs.next()){
  181. Rank rank = new Rank();
  182. rank.setMember_id(rs.getLong(1));
  183. rank.setLevel(rs.getInt(2));
  184. rank.setExperience(rs.getLong(3));
  185. rank.setRank(rs.getInt(4));
  186. ranking.add(rank);
  187. }
  188. } catch (SQLException e) {
  189. e.printStackTrace();
  190. } finally {
  191. try { rs.close(); } catch (Exception e) { /* ignored */ }
  192. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  193. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  194. }
  195. }
  196.  
  197. //Server table
  198. public static void SQLgetServer(long _guild_id){
  199. Connection myConn = null;
  200. PreparedStatement stmt = null;
  201. ResultSet rs = null;
  202. try {
  203. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  204. String sql = ("SELECT * FROM Server WHERE Guild_ID = ?");
  205. stmt = myConn.prepareStatement(sql);
  206. stmt.setLong(1, _guild_id);
  207. rs = stmt.executeQuery();
  208. if(rs.next()){
  209. setFK_RankingSystem(rs.getInt(3));
  210. setRole(rs.getLong(4), 0);
  211. setRole(rs.getLong(5), 1);
  212. setRole(rs.getLong(6), 2);
  213. setRole(rs.getLong(7), 3);
  214. setRole(rs.getLong(8), 4);
  215. setRole(rs.getLong(9), 5);
  216. setRole(rs.getLong(10), 6);
  217. setRole(rs.getLong(11), 7);
  218. setRole(rs.getLong(12), 8);
  219. setRole(rs.getLong(13), 9);
  220. }
  221. } catch (SQLException e) {
  222. e.printStackTrace();
  223. } finally {
  224. try { rs.close(); } catch (Exception e) { /* ignored */ }
  225. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  226. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  227. }
  228. }
  229.  
  230. public static void SQLgetGuild_ID(long _guild_id){
  231. Connection myConn = null;
  232. PreparedStatement stmt = null;
  233. ResultSet rs = null;
  234. try {
  235. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  236. String sql = ("SELECT Guild_ID FROM Server WHERE Guild_ID = ?");
  237. stmt = myConn.prepareStatement(sql);
  238. stmt.setLong(1, _guild_id);
  239. rs = stmt.executeQuery();
  240. if(rs.next()){
  241. setGuild_id(rs.getLong(1));
  242. }
  243. } catch (SQLException e) {
  244. e.printStackTrace();
  245. } finally {
  246. try { rs.close(); } catch (Exception e) { /* ignored */ }
  247. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  248. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  249. }
  250. }
  251.  
  252. public static void SQLgetRankingSystem(long _guild_id){
  253. Connection myConn = null;
  254. PreparedStatement stmt = null;
  255. ResultSet rs = null;
  256. try {
  257. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  258. String sql = ("SELECT LvSetting FROM Server WHERE Guild_ID = ?");
  259. stmt = myConn.prepareStatement(sql);
  260. stmt.setLong(1, _guild_id);
  261. rs = stmt.executeQuery();
  262. if(rs.next()){
  263. setFK_RankingSystem(rs.getInt(1));
  264. }
  265. } catch (SQLException e) {
  266. e.printStackTrace();
  267. } finally {
  268. try { rs.close(); } catch (Exception e) { /* ignored */ }
  269. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  270. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  271. }
  272. }
  273.  
  274. public static void SQLsetRole1(long _guild_id, long _role){
  275. Connection myConn = null;
  276. PreparedStatement stmt = null;
  277. try {
  278. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  279. String sql = ("UPDATE Server SET role1 = ? WHERE Guild_ID = ?");
  280. stmt = myConn.prepareStatement(sql);
  281. stmt.setLong(1, _role);
  282. stmt.setLong(2, _guild_id);
  283. stmt.executeUpdate();
  284. } catch (SQLException e) {
  285. e.printStackTrace();
  286. } finally {
  287. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  288. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  289. }
  290. }
  291.  
  292. public static void SQLsetRole2(long _guild_id, long _role){
  293. Connection myConn = null;
  294. PreparedStatement stmt = null;
  295. try {
  296. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  297. String sql = ("UPDATE Server SET role2 = ? WHERE Guild_ID = ?");
  298. stmt = myConn.prepareStatement(sql);
  299. stmt.setLong(1, _role);
  300. stmt.setLong(2, _guild_id);
  301. stmt.executeUpdate();
  302. } catch (SQLException e) {
  303. e.printStackTrace();
  304. } finally {
  305. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  306. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  307. }
  308. }
  309.  
  310. public static void SQLsetRole3(long _guild_id, long _role){
  311. Connection myConn = null;
  312. PreparedStatement stmt = null;
  313. try {
  314. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  315. String sql = ("UPDATE Server SET role3 = ? WHERE Guild_ID = ?");
  316. stmt = myConn.prepareStatement(sql);
  317. stmt.setLong(1, _role);
  318. stmt.setLong(2, _guild_id);
  319. stmt.executeUpdate();
  320. } catch (SQLException e) {
  321. e.printStackTrace();
  322. } finally {
  323. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  324. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  325. }
  326. }
  327.  
  328. public static void SQLsetRole4(long _guild_id, long _role){
  329. Connection myConn = null;
  330. PreparedStatement stmt = null;
  331. try {
  332. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  333. String sql = ("UPDATE Server SET role4 = ? WHERE Guild_ID = ?");
  334. stmt = myConn.prepareStatement(sql);
  335. stmt.setLong(1, _role);
  336. stmt.setLong(2, _guild_id);
  337. stmt.executeUpdate();
  338. } catch (SQLException e) {
  339. e.printStackTrace();
  340. } finally {
  341. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  342. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  343. }
  344. }
  345.  
  346. public static void SQLsetRole5(long _guild_id, long _role){
  347. Connection myConn = null;
  348. PreparedStatement stmt = null;
  349. try {
  350. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  351. String sql = ("UPDATE Server SET role5 = ? WHERE Guild_ID = ?");
  352. stmt = myConn.prepareStatement(sql);
  353. stmt.setLong(1, _role);
  354. stmt.setLong(2, _guild_id);
  355. stmt.executeUpdate();
  356. } catch (SQLException e) {
  357. e.printStackTrace();
  358. } finally {
  359. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  360. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  361. }
  362. }
  363.  
  364. public static void SQLsetRole6(long _guild_id, long _role){
  365. Connection myConn = null;
  366. PreparedStatement stmt = null;
  367. try {
  368. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  369. String sql = ("UPDATE Server SET role6 = ? WHERE Guild_ID = ?");
  370. stmt = myConn.prepareStatement(sql);
  371. stmt.setLong(1, _role);
  372. stmt.setLong(2, _guild_id);
  373. stmt.executeUpdate();
  374. } catch (SQLException e) {
  375. e.printStackTrace();
  376. } finally {
  377. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  378. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  379. }
  380. }
  381.  
  382. public static void SQLsetRole7(long _guild_id, long _role){
  383. Connection myConn = null;
  384. PreparedStatement stmt = null;
  385. try {
  386. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  387. String sql = ("UPDATE Server SET role7 = ? WHERE Guild_ID = ?");
  388. stmt = myConn.prepareStatement(sql);
  389. stmt.setLong(1, _role);
  390. stmt.setLong(2, _guild_id);
  391. stmt.executeUpdate();
  392. } catch (SQLException e) {
  393. e.printStackTrace();
  394. } finally {
  395. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  396. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  397. }
  398. }
  399.  
  400. public static void SQLsetRole8(long _guild_id, long _role){
  401. Connection myConn = null;
  402. PreparedStatement stmt = null;
  403. try {
  404. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  405. String sql = ("UPDATE Server SET role8 = ? WHERE Guild_ID = ?");
  406. stmt = myConn.prepareStatement(sql);
  407. stmt.setLong(1, _role);
  408. stmt.setLong(2, _guild_id);
  409. stmt.executeUpdate();
  410. } catch (SQLException e) {
  411. e.printStackTrace();
  412. } finally {
  413. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  414. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  415. }
  416. }
  417.  
  418. public static void SQLsetRole9(long _guild_id, long _role){
  419. Connection myConn = null;
  420. PreparedStatement stmt = null;
  421. try {
  422. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  423. String sql = ("UPDATE Server SET role9 = ? WHERE Guild_ID = ?");
  424. stmt = myConn.prepareStatement(sql);
  425. stmt.setLong(1, _role);
  426. stmt.setLong(2, _guild_id);
  427. stmt.executeUpdate();
  428. } catch (SQLException e) {
  429. e.printStackTrace();
  430. } finally {
  431. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  432. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  433. }
  434. }
  435.  
  436. public static void SQLsetRole10(long _guild_id, long _role){
  437. Connection myConn = null;
  438. PreparedStatement stmt = null;
  439. try {
  440. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  441. String sql = ("UPDATE Server SET role10 = ? WHERE Guild_ID = ?");
  442. stmt = myConn.prepareStatement(sql);
  443. stmt.setLong(1, _role);
  444. stmt.setLong(2, _guild_id);
  445. stmt.executeUpdate();
  446. } catch (SQLException e) {
  447. e.printStackTrace();
  448. } finally {
  449. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  450. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  451. }
  452. }
  453.  
  454. public static void SQLsetEmptyRoles(long _guild_id){
  455. Connection myConn = null;
  456. PreparedStatement stmt = null;
  457. try {
  458. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  459. String sql = ("UPDATE Server SET role1 = null, role2 = null, role3 = null, role4 = null, role5 = null, role6 = null, role7 = null, role8 = null, role9 = null, role10 = null WHERE Guild_ID = ?");
  460. stmt = myConn.prepareStatement(sql);
  461. stmt.setLong(1, _guild_id);
  462. stmt.executeUpdate();
  463. } catch (SQLException e) {
  464. e.printStackTrace();
  465. } finally {
  466. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  467. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  468. }
  469. }
  470.  
  471. public static void SQLfillServer(long _guild_id, int _rankingSystem){
  472. Connection myConn = null;
  473. PreparedStatement stmt = null;
  474. try {
  475. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  476. String sql = ("INSERT INTO Server (Server_ID, Guild_ID, LvSetting, role1, role2, role3, role4, role5, role6, role7, role8, role9, role10) VALUES (null, ?, ?, null, null, null, null, null, null, null, null, null, null)");
  477. stmt = myConn.prepareStatement(sql);
  478. stmt.setLong(1, _guild_id);
  479. stmt.setInt(2, _rankingSystem);
  480. stmt.executeUpdate();
  481. } catch (SQLException e) {
  482. e.printStackTrace();
  483. } finally {
  484. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  485. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  486. }
  487. }
  488.  
  489. public static void SQLupdateRankingSystem(long _guild_id, int _rankingSystem){
  490. Connection myConn = null;
  491. PreparedStatement stmt = null;
  492. try {
  493. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  494. String sql = ("UPDATE Server SET LvSetting = ? WHERE Guild_ID = ?");
  495. stmt = myConn.prepareStatement(sql);
  496. stmt.setInt(1, _rankingSystem);
  497. stmt.setLong(2, _guild_id);
  498. stmt.executeUpdate();
  499. } catch (SQLException e) {
  500. e.printStackTrace();
  501. } finally {
  502. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  503. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  504. }
  505. }
  506.  
  507. //Template table
  508. public static void SQLgetTemplate(int _rankingSystem){
  509. Connection myConn = null;
  510. PreparedStatement stmt = null;
  511. ResultSet rs = null;
  512. try {
  513. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  514. String sql = ("SELECT MaxRank, RoleLevel, description FROM Template WHERE LvSetting = ?");
  515. stmt = myConn.prepareStatement(sql);
  516. stmt.setInt(1, _rankingSystem);
  517. rs = stmt.executeQuery();
  518. if(rs.next()){
  519. setMaxRank(rs.getInt(1));
  520. setRoleAssignLevel(rs.getInt(2));
  521. setDescription(rs.getString(3));
  522. }
  523. } catch (SQLException e) {
  524. e.printStackTrace();
  525. } finally {
  526. try { rs.close(); } catch (Exception e) { /* ignored */ }
  527. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  528. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  529. }
  530. }
  531.  
  532. public static void SQLgetNumberOfRankingSystems(){
  533. Connection myConn = null;
  534. PreparedStatement stmt = null;
  535. ResultSet rs = null;
  536. try {
  537. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/RankingSystem", username, password);
  538. String sql = ("SELECT MAX(LvSetting) FROM Template");
  539. stmt = myConn.prepareStatement(sql);
  540. rs = stmt.executeQuery();
  541. if(rs.next()){
  542. setNumberOfRankingSystems(rs.getInt(1));
  543. }
  544. } catch (SQLException e) {
  545. e.printStackTrace();
  546. } finally {
  547. try { rs.close(); } catch (Exception e) { /* ignored */ }
  548. try { stmt.close(); } catch (Exception e) { /* ignored */ }
  549. try { myConn.close(); } catch (Exception e) { /* ignored */ }
  550. }
  551. }
  552.  
  553.  
  554.  
  555. public static void setUserList_id(Integer _userlist_id){
  556. userlist_id = _userlist_id;
  557. }
  558. public static void setUser_id(long _user_id){
  559. user_id = _user_id;
  560. }
  561. public static void setFK_Guild_id(long _fk_guild_id){
  562. fk_guild_id = _fk_guild_id;
  563. }
  564. public static void setLevel(Integer _level){
  565. level = _level;
  566. }
  567. public static void setCurrentExperience(Integer _currentExperience){
  568. currentExperience = _currentExperience;
  569. }
  570. public static void setRankUpExperience(Integer _rankUpExperience){
  571. rankUpExperience = _rankUpExperience;
  572. }
  573. public static void setExperience(long _experience){
  574. experience = _experience;
  575. }
  576. public static void setGuild_id(long _guild_id){
  577. guild_id = _guild_id;
  578. }
  579. public static void setFK_RankingSystem(Integer _fk_rankingSystem){
  580. fk_rankingSystem = _fk_rankingSystem;
  581. }
  582. public static void setRole(long _role, int index){
  583. role[index] = _role;
  584. }
  585. public static void setCurrency(long _currency){
  586. currency = _currency;
  587. }
  588. public static void setRankingSystem(Integer _rankingSystem){
  589. rankingSystem = _rankingSystem;
  590. }
  591. public static void setMaxRank(Integer _maxRank){
  592. maxRank = _maxRank;
  593. }
  594. public static void setRoleAssignLevel(Integer _roleAssignLevel){
  595. roleAssignLevel = _roleAssignLevel;
  596. }
  597. public static void setDescription(String _description){
  598. description = _description;
  599. }
  600. public static void setNumberOfRankingSystems(Integer _numberOfRankingSystems){
  601. numberOfRankingSystems = _numberOfRankingSystems;
  602. }
  603.  
  604.  
  605. public static Integer getUserList_id(){
  606. return userlist_id;
  607. }
  608. public static long getUser_id(){
  609. return user_id;
  610. }
  611. public static long getFK_Guild_id(){
  612. return fk_guild_id;
  613. }
  614. public static Integer getLevel(){
  615. return level;
  616. }
  617. public static Integer getCurrentExperience(){
  618. return currentExperience;
  619. }
  620. public static Integer getRankUpExperience(){
  621. return rankUpExperience;
  622. }
  623. public static long getExperience(){
  624. return experience;
  625. }
  626. public static long getGuild_id(){
  627. return guild_id;
  628. }
  629. public static Integer getFK_RankingSystem(){
  630. return fk_rankingSystem;
  631. }
  632. public static long getRole(int index){
  633. return role[index];
  634. }
  635. public static long getCurrency(){
  636. return currency;
  637. }
  638. public static Integer getRankingSystem(){
  639. return rankingSystem;
  640. }
  641. public static Integer getMaxRank(){
  642. return maxRank;
  643. }
  644. public static Integer getRoleAssignLevel(){
  645. return roleAssignLevel;
  646. }
  647. public static String getDescription(){
  648. return description;
  649. }
  650. public static Integer getNumberOfRankingSystems(){
  651. return numberOfRankingSystems;
  652. }
  653. public static ArrayList<Rank> getRanking(){
  654. return ranking;
  655. }
  656.  
  657. public static void clearArrayList(){
  658. ranking.clear();
  659. }
  660. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement