All Forums Database
nonametekno 5 posts Joined 04/11
29 Jul 2011
JDBC | Unable to update the result set through a JTable

Hi,
when I try to update the updatable result set returned by a query through a stand alone Java application, an error is caught.
The same update algorithm updates Oracle, MySQL and SQL Server databases successfully.

Here the obtained stack trace:

com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 13.10.00.18] [Error 1244] [SQLState HY000] Column index value 0 is outside the valid range of 1 through 51
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJ DBCException(ErrorFactory.java:93)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJ DBCException(ErrorFactory.java:73)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJ DBCException(ErrorFactory.java:101)
at com.teradata.jdbc.jdbc_4.ResultSetRow.getValue(ResultS etRow.java:53)
at com.teradata.jdbc.jdbc_4.TDResultSet.getObjectFromCurr entRow(TDResultSet.java:185)
at com.teradata.jdbc.jdbc_4.TDResultSet.internalGetObject (TDResultSet.java:2028)
at com.teradata.jdbc.jdbc_4.TDResultSet.getObject(TDResul tSet.java:2013)
at com.teradata.jdbc.jdbc_4.ResultSetUpdater.generateUpda teStatement(ResultSetUpdater.java:1534)
at com.teradata.jdbc.jdbc_4.ResultSetUpdater.updateRow(Re sultSetUpdater.java:259)
at com.teradata.jdbc.jdbc_4.TDResultSet.updateRow(TDResul tSet.java:850)
at net.sourceforge.open_teradata_viewer.ResultSetTable.ed itingStopped(ResultSetTable.java:207)
at javax.swing.AbstractCellEditor.fireEditingStopped(Unkn own Source)
at javax.swing.DefaultCellEditor$EditorDelegate.stopCellE diting(Unknown Source)
at javax.swing.DefaultCellEditor.stopCellEditing(Unknown Source)
at javax.swing.JTable$GenericEditor.stopCellEditing(Unkno wn Source)
at javax.swing.DefaultCellEditor$EditorDelegate.actionPer formed(Unknown Source)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Un known Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent( Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEve nt(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertio ns(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unk nown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPri vilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Un known Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unkno wn Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Un known Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Open Teradata Viewer 0.06c (28/07/2011)
Windows XP 5.1 Service Pack 3 x86
Java(TM) SE Runtime Environment 1.6.0_24-b07
jdbc:teradata://../ database=..,DBS_PORT=1025,CHARSET=UTF8,LOGMECH=LDAP,LO GDATA=..@@..
com.teradata.jdbc.TeraDriver
select * from EMP where NAME = 'JONES'

Here the Java code:

public final class ResultSetTable extends JTable {

...
...
...

@Override
public void editingStopped(ChangeEvent e) {
super.editingStopped(e);
ResultSet resultSet = Context.getInstance().getResultSet();
int column = getSelectedColumn();
Object value = null;
try {
int origRow = getOriginalSelectedRow();
resultSet.first();
resultSet.relative(origRow);
value = resultSet.getObject(column + 1);
if (value == null || !value.toString().equals(getTableValue())) {
String log = ("" + value).trim();
update(column + 1, getTableValue());
resultSet.updateRow();
value = resultSet.getObject(column + 1);
log += " -> " + ("" + resultSet.getObject(column + 1)).trim();
}
} catch (Throwable t) {
if (e == null) {
// explicitly invoked
throw new RuntimeException(t.getMessage(), t);
}
ExceptionDialog.showException(t);
} finally {
try {
if (value != null) {
setTableValue(value);
}
} catch (Exception e1) {
ExceptionDialog.hideException(e1);
}
}
}

...
...
...
}

Thanks in advance,
Daniel.

nonametekno 5 posts Joined 04/11
27 Sep 2011

It seems to work fine with version 14.00.00.01 JDBC driver.

Thanks!!

 

D.

tomnolan 594 posts Joined 01/08
27 Sep 2011

This problem corresponds to:

JDBC DR 153226 Updatable ResultSet Error 1244 Column index value 0 is outside the valid range

which is fixed in Teradata JDBC Driver version 13.10.00.27 and later, as noted in the readme.txt.
 

Thank you for reporting the problem.

--Tom

 

You must sign in to leave a comment.