Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. CREATE TABLE jtest (
  2. ID NUMBER(3) PRIMARY KEY,
  3. TEXT VARCHAR2(30) NULL
  4. );
  5. INSERT INTO jtest VALUES (1, 'Test1');
  6. INSERT INTO jtest VALUES (2, 'NULL');
  7.  
  8. public class nullstring {
  9.  
  10. final static String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
  11. final static String DB_URL = "jdbc:oracle:thin:@myhost:1521:xe";
  12. final static String DB_USER = "myuser";
  13. final static String DB_PASS = "myuserpw";
  14.  
  15. public static void main(String[] args) throws ClassNotFoundException, SQLException, UnsupportedEncodingException {
  16. Class.forName(JDBC_DRIVER);
  17.  
  18. Connection hDB = null;
  19. hDB = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
  20.  
  21. String sCelldata = "";
  22. Statement oStatement = null;
  23. List<Model> oDatalist = new ArrayList<>();
  24.  
  25. oStatement = hDB.createStatement();
  26. ResultSet oResult = oStatement.executeQuery("SELECT id, text FROM jtest");
  27.  
  28. while (oResult.next()) {
  29. ObservableList<String> aCells = FXCollections.observableArrayList();
  30. for (int i = 1 ; i < (oResult.getMetaData().getColumnCount() + 1); i++) {
  31. String test = "NULL";
  32. if ( test == "NULL" ) {
  33. System.out.println(">> 1111111111111111111111111111111");
  34. }
  35. if ( oResult.getString(i) == "NULL" ) {
  36. System.out.println(">> 2222222222222222222222222222222");
  37. }
  38. sCelldata = URLDecoder.decode(oResult.getString(i), "UTF-8");
  39. if ( sCelldata == "NULL" ) {
  40. System.out.println(">> 3333333333333333333333333333333");
  41. }
  42.  
  43. aCells.add(sCelldata);
  44. System.out.println("> [" + i + "] " + sCelldata);
  45. sCelldata = "";
  46. }
  47. oDatalist.add(new Model(aCells));
  48. }
  49.  
  50. hDB.close();
  51. }
  52. }
  53.  
  54. package nullstring;
  55.  
  56. import javafx.beans.property.SimpleStringProperty;
  57. import javafx.collections.ObservableList;
  58.  
  59. public class Model {
  60. private final SimpleStringProperty id = new SimpleStringProperty("");
  61. private final SimpleStringProperty text = new SimpleStringProperty("");
  62.  
  63. public Model() {
  64.  
  65. }
  66.  
  67. public Model(ObservableList<String> aParams) {
  68. setId(aParams.get(0));
  69. setText(aParams.get(1));
  70. }
  71.  
  72. public SimpleStringProperty getId() {
  73. return id;
  74. }
  75.  
  76. public void setId(String sId) {
  77. id.set(sId);
  78. }
  79.  
  80. public SimpleStringProperty getText() {
  81. return text;
  82. }
  83.  
  84. public void setText(String sText) {
  85. text.set(sText);
  86. }
  87. }
  88.  
  89. >> 1111111111111111111111111111111
  90. > [1] 1
  91. >> 1111111111111111111111111111111
  92. > [2] Test1
  93. >> 1111111111111111111111111111111
  94. > [1] 2
  95. >> 1111111111111111111111111111111
  96. > [2] NULL
  97. >> 1111111111111111111111111111111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement