This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 206233
Collapse All | Expand All

(-)db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java (+7 lines)
Lines 76-81 Link Here
76
    protected JButton button;
76
    protected JButton button;
77
    protected JPopupMenu popup;
77
    protected JPopupMenu popup;
78
    protected JTable table;
78
    protected JTable table;
79
    protected JMenuItem saveContentMenuItem;
79
80
80
    public BlobFieldTableCellEditor() {
81
    public BlobFieldTableCellEditor() {
81
        button = new JButton();
82
        button = new JButton();
Lines 99-104 Link Here
99
                fireEditingCanceled();
100
                fireEditingCanceled();
100
            }
101
            }
101
        });
102
        });
103
        saveContentMenuItem = miLobSaveAction;
102
        popup.add(miLobSaveAction);
104
        popup.add(miLobSaveAction);
103
        final JMenuItem miLobLoadAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "loadLob.title"));
105
        final JMenuItem miLobLoadAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "loadLob.title"));
104
        miLobLoadAction.addActionListener(new ActionListener() {
106
        miLobLoadAction.addActionListener(new ActionListener() {
Lines 136-141 Link Here
136
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
138
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
137
        currentValue = (java.sql.Blob) value;
139
        currentValue = (java.sql.Blob) value;
138
        if (currentValue != null) {
140
        if (currentValue != null) {
141
            saveContentMenuItem.setEnabled(true);
139
            try {
142
            try {
140
                long size = currentValue.length();
143
                long size = currentValue.length();
141
                StringBuilder stringValue = new StringBuilder();
144
                StringBuilder stringValue = new StringBuilder();
Lines 153-158 Link Here
153
                button.setText("<BLOB of unknown size>");
156
                button.setText("<BLOB of unknown size>");
154
            }
157
            }
155
        } else {
158
        } else {
159
            saveContentMenuItem.setEnabled(false);
156
            button.setText("<NULL>");
160
            button.setText("<NULL>");
157
        }
161
        }
158
        this.table = table;
162
        this.table = table;
Lines 173-178 Link Here
173
    }
177
    }
174
178
175
    private void saveLobToFile(Blob b) {
179
    private void saveLobToFile(Blob b) {
180
        if(b == null) {
181
            return;
182
        }
176
        JFileChooser c = new JFileChooser();
183
        JFileChooser c = new JFileChooser();
177
        int fileDialogState = c.showSaveDialog(table);
184
        int fileDialogState = c.showSaveDialog(table);
178
        if (fileDialogState == JFileChooser.APPROVE_OPTION) {
185
        if (fileDialogState == JFileChooser.APPROVE_OPTION) {
(-)db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (+7 lines)
Lines 118-123 Link Here
118
    protected JTable table;
118
    protected JTable table;
119
    protected int currentRow;
119
    protected int currentRow;
120
    protected int currentColumn;
120
    protected int currentColumn;
121
    protected JMenuItem saveContentMenuItem;
121
    
122
    
122
    public ClobFieldTableCellEditor() {
123
    public ClobFieldTableCellEditor() {
123
        button = new JButton();
124
        button = new JButton();
Lines 141-146 Link Here
141
                fireEditingCanceled();
142
                fireEditingCanceled();
142
            }
143
            }
143
        });
144
        });
145
        saveContentMenuItem = miLobSaveAction;
144
        popup.add(miLobSaveAction);
146
        popup.add(miLobSaveAction);
145
        final JMenuItem miLobEditAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClob.title"));
147
        final JMenuItem miLobEditAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClob.title"));
146
        miLobEditAction.addActionListener(new ActionListener() {
148
        miLobEditAction.addActionListener(new ActionListener() {
Lines 189-194 Link Here
189
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
191
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
190
        currentValue = (java.sql.Clob) value;
192
        currentValue = (java.sql.Clob) value;
191
        if (currentValue != null) {
193
        if (currentValue != null) {
194
            saveContentMenuItem.setEnabled(true);
192
            try {
195
            try {
193
                long size = currentValue.length();
196
                long size = currentValue.length();
194
                StringBuilder stringValue = new StringBuilder();
197
                StringBuilder stringValue = new StringBuilder();
Lines 206-211 Link Here
206
                button.setText("<CLOB of unknown size>");
209
                button.setText("<CLOB of unknown size>");
207
            }
210
            }
208
        } else {
211
        } else {
212
            saveContentMenuItem.setEnabled(false);
209
            button.setText("<NULL>");
213
            button.setText("<NULL>");
210
        }
214
        }
211
        this.currentColumn = column;
215
        this.currentColumn = column;
Lines 228-233 Link Here
228
    }
232
    }
229
    
233
    
230
    private void saveLobToFile(Clob b) {
234
    private void saveLobToFile(Clob b) {
235
        if (b == null) {
236
            return;
237
        }
231
        CharsetSelector charset = new CharsetSelector();
238
        CharsetSelector charset = new CharsetSelector();
232
        JFileChooser c = new JFileChooser();
239
        JFileChooser c = new JFileChooser();
233
        c.setAccessory(charset);
240
        c.setAccessory(charset);
(-)db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java (-7 / +6 lines)
Lines 206-220 Link Here
206
            case Types.VARBINARY:
206
            case Types.VARBINARY:
207
            case Types.LONGVARBINARY:
207
            case Types.LONGVARBINARY:
208
            case Types.BLOB: {
208
            case Types.BLOB: {
209
                // Try to get a blob object (delay loading till the data is used!)
210
                try {
209
                try {
211
                    Blob blob = rs.getBlob(index);
210
                    Blob blob = rs.getBlob(index);
212
211
213
                    Object result = null;
212
                    Object result = null;
214
                    
213
                    
215
                    if (! rs.wasNull()) {
214
                    if (!rs.wasNull()) {
216
                        result = new FileBackedBlob(blob.getBinaryStream());
215
                        result = new FileBackedBlob(blob.getBinaryStream());
217
                    }
218
                    
216
                    
219
                    try {
217
                    try {
220
                        blob.free();
218
                        blob.free();
Lines 225-230 Link Here
225
                        // DBMS failed to free resource or does not support call
223
                        // DBMS failed to free resource or does not support call
226
                        // ignore this, as we can't do more
224
                        // ignore this, as we can't do more
227
                    }
225
                    }
226
                    }
228
                    
227
                    
229
                    return result;
228
                    return result;
230
                } catch (SQLException ex) {
229
                } catch (SQLException ex) {
Lines 258-272 Link Here
258
            case -16:
257
            case -16:
259
            case Types.CLOB:
258
            case Types.CLOB:
260
            case 2011: /*NCLOB */ {
259
            case 2011: /*NCLOB */ {
261
                // Try to get a blob object (delay loading till the data is used!)
262
                try {
260
                try {
263
                    Clob clob = rs.getClob(index);
261
                    Clob clob = rs.getClob(index);
264
262
265
                    Object result = null;
263
                    Object result = null;
266
                    
264
                    
267
                    if (! rs.wasNull()) {
265
                    if (!rs.wasNull()) {
268
                        result =  new FileBackedClob(clob.getCharacterStream());
266
                        result = new FileBackedClob(clob.getCharacterStream());
269
                    }
267
270
                    try {
268
                    try {
271
                        clob.free();
269
                        clob.free();
272
                    } catch (java.lang.AbstractMethodError err) {
270
                    } catch (java.lang.AbstractMethodError err) {
Lines 276-281 Link Here
276
                        // DBMS failed to free resource or does not support call
274
                        // DBMS failed to free resource or does not support call
277
                        // ignore this, as we can't do more
275
                        // ignore this, as we can't do more
278
                    }
276
                    }
277
                    }
279
                    
278
                    
280
                    return result;
279
                    return result;
281
                    
280
                    

Return to bug 206233