Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.net.*;
- import java.io.*;
- import java.util.*;
- import java.lang.*;
- public class TestConnection {
- public static void main(String args[]) {
- Connection con = null;
- Statement st = null;
- ResultSet auth = null;
- ResultSet given = null;
- String url = "jdbc:mysql://localhost:3306/";
- String db = "vote4gold";
- String driver = "com.mysql.jdbc.Driver";
- String user = "root";
- String pass = "";
- try {
- Class.forName(driver);
- con = DriverManager.getConnection(url + db, user, pass);
- con.setAutoCommit(false);
- st = con.createStatement();
- String give = "SELECT `given` FROM `has_voted` WHERE `ip` LIKE '+thisIp.getHostAddress()'";
- given = st.executeQuery(give);
- while (given.next()) {
- if (given.getInt("given") > 0) {
- System.out.println("You've already recieved a reward for the last time you voted, but thanks again for voting.");
- } else {
- System.out.println("Thanks for voting! You've been rewarded 25m gold! Vote again tomorrow!");
- String sql = "SELECT has_voted (given) Replace('0', '0', '1')";
- int rows = st.executeUpdate("UPDATE has_voted SET given = 1 WHERE given = 0");
- System.out.println("Given reward column set to 1 for the ip address:");//+thisIp.getHostAddress()*
- }
- }
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement