Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- 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 'hello'";
- given = st.executeQuery(give);
- //if given equals 0 I want it to print "Thanks for voting."
- //if given equals 1 I want it to say "Thanks again for voting."
- System.out.println("Given Reward(0=no 1=yes)"); //in the future this won't matter I just use it for testing purposes as of the moment
- while (given.next()) {
- System.out.println(given.getString("given"));
- }
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement