Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE jtest (
- ID NUMBER(3) PRIMARY KEY,
- TEXT VARCHAR2(30) NULL
- );
- INSERT INTO jtest VALUES (1, 'Test1');
- INSERT INTO jtest VALUES (2, 'NULL');
- public class nullstring {
- final static String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
- final static String DB_URL = "jdbc:oracle:thin:@myhost:1521:xe";
- final static String DB_USER = "myuser";
- final static String DB_PASS = "myuserpw";
- public static void main(String[] args) throws ClassNotFoundException, SQLException, UnsupportedEncodingException {
- Class.forName(JDBC_DRIVER);
- Connection hDB = null;
- hDB = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
- String sCelldata = "";
- Statement oStatement = null;
- List<Model> oDatalist = new ArrayList<>();
- oStatement = hDB.createStatement();
- ResultSet oResult = oStatement.executeQuery("SELECT id, text FROM jtest");
- while (oResult.next()) {
- ObservableList<String> aCells = FXCollections.observableArrayList();
- for (int i = 1 ; i < (oResult.getMetaData().getColumnCount() + 1); i++) {
- String test = "NULL";
- if ( test == "NULL" ) {
- System.out.println(">> 1111111111111111111111111111111");
- }
- if ( oResult.getString(i) == "NULL" ) {
- System.out.println(">> 2222222222222222222222222222222");
- }
- sCelldata = URLDecoder.decode(oResult.getString(i), "UTF-8");
- if ( sCelldata == "NULL" ) {
- System.out.println(">> 3333333333333333333333333333333");
- }
- aCells.add(sCelldata);
- System.out.println("> [" + i + "] " + sCelldata);
- sCelldata = "";
- }
- oDatalist.add(new Model(aCells));
- }
- hDB.close();
- }
- }
- package nullstring;
- import javafx.beans.property.SimpleStringProperty;
- import javafx.collections.ObservableList;
- public class Model {
- private final SimpleStringProperty id = new SimpleStringProperty("");
- private final SimpleStringProperty text = new SimpleStringProperty("");
- public Model() {
- }
- public Model(ObservableList<String> aParams) {
- setId(aParams.get(0));
- setText(aParams.get(1));
- }
- public SimpleStringProperty getId() {
- return id;
- }
- public void setId(String sId) {
- id.set(sId);
- }
- public SimpleStringProperty getText() {
- return text;
- }
- public void setText(String sText) {
- text.set(sText);
- }
- }
- >> 1111111111111111111111111111111
- > [1] 1
- >> 1111111111111111111111111111111
- > [2] Test1
- >> 1111111111111111111111111111111
- > [1] 2
- >> 1111111111111111111111111111111
- > [2] NULL
- >> 1111111111111111111111111111111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement