Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.36 KB | None | 0 0
  1. package de.noelbank.mysql;
  2.  
  3. import java.io.PrintStream;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.sql.Statement;
  9.  
  10. public class mysql
  11. {
  12. public static String host = "127.0.0.1";
  13. public static String port = "3306";
  14. public static String database = "mcrpg";
  15. public static String username = "minecraft";
  16. public static String password = "failfail1";
  17. public static Connection con;
  18.  
  19. public static void connect()
  20. {
  21. if (!isConnected()) {
  22. try
  23. {
  24. con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  25. System.out.println("[MYSQL] +");
  26. }
  27. catch (SQLException e)
  28. {
  29. e.printStackTrace();
  30. }
  31. }
  32. }
  33.  
  34. public static void disconnect()
  35. {
  36. if (isConnected()) {
  37. try
  38. {
  39. con.close();
  40. System.out.println("[MYSQL] -");
  41. }
  42. catch (SQLException e)
  43. {
  44. e.printStackTrace();
  45. }
  46. }
  47. }
  48.  
  49. public static boolean isConnected()
  50. {
  51. return con != null;
  52. }
  53.  
  54. public static boolean getMYSQL()
  55. {
  56. if (!isConnected()) {
  57. try
  58. {
  59. con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  60. }
  61. catch (SQLException e)
  62. {
  63. e.printStackTrace();
  64. }
  65. }
  66. return true;
  67. }
  68.  
  69. public static Connection getConnection()
  70. {
  71. return con;
  72. }
  73.  
  74. public static void update(String qry)
  75. {
  76. if (isConnected()) {
  77. try
  78. {
  79. con.createStatement().executeUpdate(qry);
  80. }
  81. catch (SQLException e)
  82. {
  83. e.printStackTrace();
  84. }
  85. }
  86. }
  87.  
  88. public static ResultSet getResult(String qrv)
  89. {
  90. if (isConnected()) {
  91. try
  92. {
  93. con.createStatement().executeQuery(qrv);
  94. }
  95. catch (SQLException e)
  96. {
  97. e.printStackTrace();
  98. }
  99. }
  100. return null;
  101. }
  102.  
  103. public static boolean isBanned(String uuid)
  104. {
  105. try
  106. {
  107. Statement statement = con.createStatement();
  108. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
  109. return rs.next();
  110. }
  111. catch (SQLException e)
  112. {
  113. e.printStackTrace();
  114. }
  115. return false;
  116. }
  117.  
  118. public static boolean isunBanned(String name)
  119. {
  120. try
  121. {
  122. Statement statement = con.createStatement();
  123. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE name='" + name + "'");
  124. return rs.next();
  125. }
  126. catch (SQLException e)
  127. {
  128. e.printStackTrace();
  129. }
  130. return false;
  131. }
  132.  
  133. public static String getReason(String uuid)
  134. {
  135. try
  136. {
  137. Statement statement = con.createStatement();
  138. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID= '" + uuid + "'");
  139. if (rs.next()) {
  140. return rs.getString("cause");
  141. }
  142. }
  143. catch (SQLException e)
  144. {
  145. e.printStackTrace();
  146. }
  147. return "";
  148. }
  149.  
  150. public static String getTime(String uuid)
  151. {
  152. try
  153. {
  154. Statement statement = con.createStatement();
  155. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
  156. if (rs.next()) {
  157. return rs.getString("time");
  158. }
  159. }
  160. catch (SQLException e)
  161. {
  162. e.printStackTrace();
  163. }
  164. return "";
  165. }
  166.  
  167. public static String getIP(String uuid)
  168. {
  169. try
  170. {
  171. Statement statement = con.createStatement();
  172. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
  173. if (rs.next()) {
  174. return rs.getString("ip");
  175. }
  176. }
  177. catch (SQLException e)
  178. {
  179. e.printStackTrace();
  180. }
  181. return "";
  182. }
  183.  
  184. public static String getID(String uuid)
  185. {
  186. try
  187. {
  188. Statement statement = con.createStatement();
  189. ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
  190. if (rs.next()) {
  191. return rs.getString("id");
  192. }
  193. }
  194. catch (SQLException e)
  195. {
  196. e.printStackTrace();
  197. }
  198. return "";
  199. }
  200.  
  201. public static boolean isMuted(String uuid)
  202. {
  203. try
  204. {
  205. Statement statement = con.createStatement();
  206. ResultSet rs = statement.executeQuery("SELECT * FROM muted WHERE UUID='" + uuid + "'");
  207. return rs.next();
  208. }
  209. catch (SQLException e)
  210. {
  211. e.printStackTrace();
  212. }
  213. return false;
  214. }
  215.  
  216. public static String getMute(String uuid)
  217. {
  218. try
  219. {
  220. Statement statement = con.createStatement();
  221. ResultSet rs = statement.executeQuery("SELECT * FROM muted WHERE UUID='" + uuid + "'");
  222. if (rs.next()) {
  223. return rs.getString("grund");
  224. }
  225. }
  226. catch (SQLException e)
  227. {
  228. e.printStackTrace();
  229. }
  230. return "";
  231. }
  232.  
  233. public static boolean isWartungon(String way)
  234. {
  235. try
  236. {
  237. Statement statement = con.createStatement();
  238. ResultSet rs = statement.executeQuery("SELECT * FROM system WHERE wartung='" + way + "'");
  239. return rs.next();
  240. }
  241. catch (SQLException e)
  242. {
  243. e.printStackTrace();
  244. }
  245. return false;
  246. }
  247.  
  248. public static boolean isWartung(String uuid)
  249. {
  250. try
  251. {
  252. Statement statement = con.createStatement();
  253. ResultSet rs = statement.executeQuery("SELECT * FROM wartung WHERE UUID='" + uuid + "'");
  254. return rs.next();
  255. }
  256. catch (SQLException e)
  257. {
  258. e.printStackTrace();
  259. }
  260. return false;
  261. }
  262.  
  263. public static boolean isunWartung(String name)
  264. {
  265. try
  266. {
  267. Statement statement = con.createStatement();
  268. ResultSet rs = statement.executeQuery("SELECT * FROM wartung WHERE name='" + name + "'");
  269. return rs.next();
  270. }
  271. catch (SQLException e)
  272. {
  273. e.printStackTrace();
  274. }
  275. return false;
  276. }
  277.  
  278. public static boolean isJob(String uuid)
  279. {
  280. try
  281. {
  282. Statement statement = con.createStatement();
  283. ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
  284. return rs.next();
  285. }
  286. catch (SQLException e)
  287. {
  288. e.printStackTrace();
  289. }
  290. return false;
  291. }
  292.  
  293. public static String getHolz(String uuid)
  294. {
  295. try
  296. {
  297. Statement statement = con.createStatement();
  298. ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
  299. if (rs.next()) {
  300. return rs.getString("holz");
  301. }
  302. }
  303. catch (SQLException e)
  304. {
  305. e.printStackTrace();
  306. }
  307. return "";
  308. }
  309.  
  310. public static String getMining(String uuid)
  311. {
  312. try
  313. {
  314. Statement statement = con.createStatement();
  315. ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
  316. if (rs.next()) {
  317. return rs.getString("mining");
  318. }
  319. }
  320. catch (SQLException e)
  321. {
  322. e.printStackTrace();
  323. }
  324. return "";
  325. }
  326.  
  327. public static String getJob(String uuid)
  328. {
  329. try
  330. {
  331. Statement statement = con.createStatement();
  332. ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
  333. if (rs.next()) {
  334. return rs.getString("job");
  335. }
  336. }
  337. catch (SQLException e)
  338. {
  339. e.printStackTrace();
  340. }
  341. return "";
  342. }
  343.  
  344. public static boolean isAbschluss(String uuid)
  345. {
  346. try
  347. {
  348. Statement statement = con.createStatement();
  349. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  350. return rs.next();
  351. }
  352. catch (SQLException e)
  353. {
  354. e.printStackTrace();
  355. }
  356. return false;
  357. }
  358.  
  359. public static boolean isabAbschluss(String uuid)
  360. {
  361. try
  362. {
  363. Statement statement = con.createStatement();
  364. ResultSet rs = statement.executeQuery("SELECT abschluss FROM schule WHERE UUID='" + uuid + "'");
  365. return rs.next();
  366. }
  367. catch (SQLException e)
  368. {
  369. e.printStackTrace();
  370. }
  371. return false;
  372. }
  373.  
  374. public static String getGehalt(String uuid)
  375. {
  376. try
  377. {
  378. Statement statement = con.createStatement();
  379. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  380. if (rs.next()) {
  381. return rs.getString("gehalt");
  382. }
  383. }
  384. catch (SQLException e)
  385. {
  386. e.printStackTrace();
  387. }
  388. return "";
  389. }
  390.  
  391. public static long getLohn(String uuid)
  392. {
  393. try
  394. {
  395. Statement statement = con.createStatement();
  396. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  397. if (rs.next()) {
  398. return rs.getLong("lohn");
  399. }
  400. }
  401. catch (SQLException e)
  402. {
  403. e.printStackTrace();
  404. }
  405. return 0L;
  406. }
  407.  
  408. public static String getAbschluss(String uuid)
  409. {
  410. try
  411. {
  412. Statement statement = con.createStatement();
  413. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  414. if (rs.next()) {
  415. return rs.getString("abschluss");
  416. }
  417. }
  418. catch (SQLException e)
  419. {
  420. e.printStackTrace();
  421. }
  422. return "";
  423. }
  424.  
  425. public static boolean isAbsH(String way)
  426. {
  427. try
  428. {
  429. Statement statement = con.createStatement();
  430. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE wartung='" + way + "'");
  431. return rs.next();
  432. }
  433. catch (SQLException e)
  434. {
  435. e.printStackTrace();
  436. }
  437. return false;
  438. }
  439.  
  440. public static String getAusbildung(String uuid)
  441. {
  442. try
  443. {
  444. Statement statement = con.createStatement();
  445. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  446. if (rs.next()) {
  447. return rs.getString("ausbildung");
  448. }
  449. }
  450. catch (SQLException e)
  451. {
  452. e.printStackTrace();
  453. }
  454. return "";
  455. }
  456.  
  457. public static String getBeruf(String uuid)
  458. {
  459. try
  460. {
  461. Statement statement = con.createStatement();
  462. ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
  463. if (rs.next()) {
  464. return rs.getString("beruf");
  465. }
  466. }
  467. catch (SQLException e)
  468. {
  469. e.printStackTrace();
  470. }
  471. return "";
  472. }
  473. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement