Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. import java.sql.*;
  2. import java.util.logging.Level;
  3. import java.util.logging.Logger;
  4. public class Main {
  5.  
  6. public static void main(String[] argv) {
  7. try {
  8. String url = "jdbc:sap://sapbipoc:30015/";
  9. String user="POC_USER";
  10. String password = "Pa22w0rd";
  11. Connection connection =
  12. DriverManager.getConnection(url,user,password);
  13. if (connection != null) {
  14. System.out.println("Connection to SAP HANA successful!");
  15. Statement stmt = connection.createStatement();
  16. ResultSet resultSet = stmt.executeQuery("select * from
  17. POC_USER.TEMPFORECASTS");
  18. while(resultSet.next()){
  19. System.out.println(resultSet.getString(1));
  20. }
  21.  
  22. }else{
  23. System.out.println("Connection error!");}
  24. } catch (Exception ex) {
  25. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  26. }
  27. }
  28. }
  29.  
  30. import java.sql.*;
  31. import java.util.logging.Level;
  32. import java.util.logging.Logger;
  33. public class Main {
  34.  
  35. public static void main(String[] argv) {
  36. try {
  37. String url = "jdbc:sap://172.8.162.10:30015/?databaseName=PQ0";
  38. String user="rgonzalezp";
  39. String password = "SomePassword";
  40. Connection connection =
  41. DriverManager.getConnection(url,user,password);
  42. if (connection != null) {
  43. System.out.println("Connection to SAP HANA successful!");
  44. Statement stmt = connection.createStatement();
  45. ResultSet resultSet = stmt.executeQuery("Select top 10 * from
  46. CHI_SUP.BRAND");
  47. while(resultSet.next()){
  48. System.out.println(resultSet.getString(1));
  49. }
  50.  
  51. }else{
  52. System.out.println("Connection error!");}
  53. } catch (Exception ex) {
  54. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment