Guest User

Untitled

a guest
Sep 14th, 2019
201
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. System.out.printf("%s, version %s%n",
  2.         conn.getMetaData().getDriverName(),
  3.         conn.getMetaData().getDriverVersion());
  4. // Microsoft JDBC Driver 7.4 for SQL Server, version 7.4.1.0
  5.  
  6. Statement st = conn.createStatement();
  7. ResultSet rs = st.executeQuery(
  8.         "SELECT CAST(123 AS SQL_VARIANT), CAST('abc' AS SQL_VARIANT), CAST(3.14 AS SQL_VARIANT)");
  9. rs.next();
  10. Object o1 = rs.getObject(1);
  11. System.out.println(o1.getClass().getName());  
  12. // java.lang.Integer
  13.  
  14. Object o2 = rs.getObject(2);
  15. System.out.println(o2.getClass().getName());  
  16. // java.lang.String
  17.  
  18. Object o3 = rs.getObject(3);
  19. System.out.println(o3.getClass().getName());  
  20. // java.math.BigDecimal
RAW Paste Data