Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. package FitnessMafia.Stromba;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9. public class DBcheck {
  10. public static void main(String[] args) throws SQLException {
  11. BackToSelenium dbverify = new BackToSelenium();
  12. System.out.println("-------- Oracle JDBC Connection Testing ------");
  13.  
  14. try {
  15.  
  16. Class.forName("oracle.jdbc.driver.OracleDriver");
  17.  
  18. } catch (ClassNotFoundException e) {
  19.  
  20. System.out.println("Where is your Oracle JDBC Driver?");
  21. e.printStackTrace();
  22. return;
  23.  
  24. }
  25.  
  26. System.out.println("Oracle JDBC Driver Registered!");
  27.  
  28. Connection connection = null;
  29.  
  30. try {
  31. connection = DriverManager.getConnection(
  32. "jdbc:oracle:thin:@//10.145.40.65:1521/poker.world", "*****",
  33. "*****");
  34.  
  35. } catch (SQLException e) {
  36.  
  37. System.out.println("Connection Failed! Check output console");
  38. e.printStackTrace();
  39. return;
  40.  
  41. }
  42.  
  43. if (connection != null) {
  44. System.out.println("You made it, take control your database now!");
  45. } else {
  46. System.out.println("Failed to make connection!");
  47. }
  48. System.out.println("" );
  49. Statement sqlStatement = connection.createStatement();
  50. String readRecordSQL = "SELECT name,status from CASINO.POKERTOURNAMENTS WHERE NAME = " + "'" + dbverify.tournamentName + "'" + " AND STATUS='Register'";
  51. ResultSet myResultSet = sqlStatement.executeQuery(readRecordSQL);
  52. while (myResultSet.next()) {
  53. String name=myResultSet.getString("name");
  54. String status =myResultSet.getString("status");
  55. System.out.println("Tournament name is : " + name);
  56. System.out.println("Tournament status is : " + status);
  57. if(dbverify.tournamentName.equals(name)){
  58. System.out.println("MASHINA");
  59. }else{
  60. System.out.println("k0r");
  61. }
  62. }
  63.  
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement