Revision: 6003
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6003&view=rev
Author: gerdwagner
Date: 2010-11-23 23:10:33 +0000 (Tue, 23 Nov 2010)
Log Message:
-----------
New Session property to let SQuirreL set fetch size (call Statement.setFetchSize(int)).
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecuterTask.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionProperties.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesBeanInfo.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionSQLPropertiesPanel.java
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/session/properties/I18NStrings.properties
trunk/sql12/app/src/test/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesTest.java
trunk/sql12/doc/src/main/resources/changes.txt
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecuterTask.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecuterTask.java 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecuterTask.java 2010-11-23 23:10:33 UTC (rev 6003)
@@ -150,6 +150,12 @@
try
{
+ if(props.getSQLUseFetchSize() && props.getSQLFetchSize() > 0)
+ {
+ setFetchSize(props);
+ }
+
+
final boolean correctlySupportsMaxRows = conn.getSQLMetaData()
.correctlySupportsSetMaxRows();
if (correctlySupportsMaxRows && props.getSQLLimitRows())
@@ -311,6 +317,21 @@
}
}
+ /**
+ * Set the fetchSize Arrtibute for the SQL-Statement;
+ */
+ private void setFetchSize(SessionProperties props)
+ {
+ try
+ {
+ _stmt.setFetchSize(props.getSQLFetchSize());
+ }
+ catch (Exception e)
+ {
+ s_log.error("Can't Set FetchSize", e);
+ }
+ }
+
private void setMaxRows(final SessionProperties props)
{
try
@@ -796,4 +817,4 @@
//////////////////////////////////////////////////////////////////////////////////
-}
\ No newline at end of file
+}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionProperties.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionProperties.java 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionProperties.java 2010-11-23 23:10:33 UTC (rev 6003)
@@ -86,6 +86,8 @@
String KEEP_TABLE_LAYOUT_ON_RERUN = "keepTableLayoutOnRerun";
String LIMIT_SQL_RESULT_TABS = "limitSqlResultTabs";
String REMOVE_MULTI_LINE_COMMENT = "removeMultiLineComment";
+ String SQL_USE_FETCH_SIZE = "sqlUseFetchSize";
+ String SQL_FETCH_SIZE = "sqlFetchSize";
}
private static final FontInfo DEFAULT_FONT_INFO =
@@ -237,6 +239,16 @@
private int _sqlResultTabLimit = 15;
/**
+ * The nuber of rows, which the database driver should fetch at once.
+ */
+ private int _sqlFetchSize=50;
+
+ /**
+ * Indicates that the we should use the setFetchSize() Method of an Statement.
+ */
+ private boolean _sqlUseFetchSize;
+
+ /**
* Default ctor.
*/
public SessionProperties()
@@ -565,6 +577,38 @@
oldValue, _sqlLimitRows);
}
}
+
+ /**
+ * Sets the number of rows which should be fetched at once.
+ */
+ public void setSQLFetchSize(int value)
+ {
+ if(value < 0){
+ throw new IllegalArgumentException("FetchSize must be >= 0. fetchSize=" +value);
+ }
+ if (_sqlFetchSize != value)
+ {
+ final int oldValue = _sqlFetchSize;
+ _sqlFetchSize = value;
+ getPropertyChangeReporter().firePropertyChange(
+ IPropertyNames.SQL_FETCH_SIZE,
+ oldValue, _sqlFetchSize);
+ }
+ }
+ /**
+ * Defines, if we should use {@link Statement#setFetchSize(int)}
+ */
+ public void setSQLUseFetchSize(boolean value)
+ {
+ if (_sqlUseFetchSize != value)
+ {
+ final boolean oldValue = _sqlUseFetchSize;
+ _sqlUseFetchSize = value;
+ getPropertyChangeReporter().firePropertyChange(
+ IPropertyNames.SQL_USE_FETCH_SIZE,
+ oldValue, _sqlUseFetchSize);
+ }
+ }
/**
@@ -1004,4 +1048,14 @@
}
return _propChgReporter;
}
+
+ public int getSQLFetchSize()
+ {
+ return _sqlFetchSize;
+ }
+
+ public boolean getSQLUseFetchSize()
+ {
+ return _sqlUseFetchSize;
+ }
}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesBeanInfo.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesBeanInfo.java 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesBeanInfo.java 2010-11-23 23:10:33 UTC (rev 6003)
@@ -91,6 +91,10 @@
"getSQLExecutionTabPlacement", "setSQLExecutionTabPlacement"),
new PropertyDescriptor(IPropNames.SQL_RESULTS_TAB_PLACEMENT, SessionProperties.class,
"getSQLResultsTabPlacement", "setSQLResultsTabPlacement"),
+ new PropertyDescriptor(IPropNames.SQL_USE_FETCH_SIZE, SessionProperties.class,
+ "getSQLFetchSize", "setSQLFetchSize"),
+ new PropertyDescriptor(IPropNames.SQL_FETCH_SIZE, SessionProperties.class,
+ "getSQLUseFetchSize", "setSQLUseFetchSize"),
new PropertyDescriptor(IPropNames.TABLE_CONTENTS_OUTPUT_CLASS_NAME,
SessionProperties.class, "getTableContentsOutputClassName",
"setTableContentsOutputClassName"),
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionSQLPropertiesPanel.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionSQLPropertiesPanel.java 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/properties/SessionSQLPropertiesPanel.java 2010-11-23 23:10:33 UTC (rev 6003)
@@ -129,6 +129,8 @@
private JCheckBox _commitOnClose = new JCheckBox(s_stringMgr.getString("SessionSQLPropertiesPanel.commitonclose"));
private IntegerField _sqlNbrRowsToShowField = new IntegerField(5);
private JCheckBox _sqlLimitRowsChk = new JCheckBox(s_stringMgr.getString("SessionSQLPropertiesPanel.limitrows"));
+ private JCheckBox _sqlFetchSizeChk = new JCheckBox(s_stringMgr.getString("SessionSQLPropertiesPanel.fetchSize"));
+ private IntegerField _sqlFetchSizeField = new IntegerField(5);
private JTextField _stmtSepField = new JTextField(5);
private JTextField _solCommentField = new JTextField(2);
// i18n[SessionSQLPropertiesPanel.removeMultiLineComment=Remove multi line comment (/*...*/) from SQL before sending to database]
@@ -172,8 +174,9 @@
_commitOnClose.setSelected(props.getCommitOnClosingConnection());
_sqlNbrRowsToShowField.setInt(props.getSQLNbrRowsToShow());
_sqlLimitRowsChk.setSelected(props.getSQLLimitRows());
+ _sqlFetchSizeChk.setSelected(props.getSQLUseFetchSize());
+ _sqlFetchSizeField.setInt(props.getSQLFetchSize());
-
if(null != _session)
{
IQueryTokenizer queryTokenizer = _session.getQueryTokenizer();
@@ -247,6 +250,9 @@
props.setCommitOnClosingConnection(_commitOnClose.isSelected());
props.setSQLNbrRowsToShow(_sqlNbrRowsToShowField.getInt());
props.setSQLLimitRows(_sqlLimitRowsChk.isSelected());
+ props.setSQLFetchSize(_sqlFetchSizeField.getInt());
+ props.setSQLUseFetchSize(_sqlFetchSizeChk.isSelected());
+
props.setSQLStatementSeparator(_stmtSepField.getText());
props.setStartOfLineComment(_solCommentField.getText());
props.setRemoveMultiLineComment(_removeMultiLineComment.isSelected());
@@ -277,6 +283,8 @@
_sqlNbrRowsToShowField.setEnabled(_sqlLimitRowsChk.isSelected());
+ _sqlFetchSizeField.setEnabled(_sqlFetchSizeChk.isSelected());
+
_limitSQLResultTabsField.setEnabled(_limitSQLResultTabsChk.isSelected());
// If this session doesn't share SQL history with other sessions
@@ -315,6 +323,7 @@
_autoCommitChk.addChangeListener(_controlMediator);
_sqlLimitRowsChk.addChangeListener(_controlMediator);
+ _sqlFetchSizeChk.addChangeListener(_controlMediator);
_sqlNbrRowsToShowField.setColumns(5);
_stmtSepField.setColumns(5);
@@ -346,6 +355,27 @@
++gbc.gridx;
gbc.gridwidth = GridBagConstraints.REMAINDER;
pnl.add(new JLabel(s_stringMgr.getString("SessionSQLPropertiesPanel.rows")), gbc);
+
+
+ // Show fetchSize-Option
+ ++gbc.gridy; // new line
+ gbc.gridx = 0;
+ gbc.gridwidth = 2;
+ pnl.add(_sqlFetchSizeChk, gbc);
+ gbc.gridwidth = 1;
+ gbc.gridx+=2;
+ pnl.add(_sqlFetchSizeField, gbc);
+ ++gbc.gridx;
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ pnl.add(new JLabel(s_stringMgr.getString("SessionSQLPropertiesPanel.rows")), gbc);
+
+
+
+
+
+
+
+
++gbc.gridy; // new line
gbc.gridx = 0;
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/session/properties/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/session/properties/I18NStrings.properties 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/session/properties/I18NStrings.properties 2010-11-23 23:10:33 UTC (rev 6003)
@@ -4,6 +4,7 @@
SessionSQLPropertiesPanel.commitonclose=Commit On Closing Session
SessionSQLPropertiesPanel.font=Font
SessionSQLPropertiesPanel.limitrows=SQL results - Limit rows
+SessionSQLPropertiesPanel.fetchSize=Fetch Rows at once
SessionSQLPropertiesPanel.limitsqlhistorysize=Limit SQL History Combo Size
SessionSQLPropertiesPanel.rows=rows
SessionSQLPropertiesPanel.sharesqlhistory=Share SQL History
Modified: trunk/sql12/app/src/test/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesTest.java
===================================================================
--- trunk/sql12/app/src/test/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesTest.java 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/app/src/test/java/net/sourceforge/squirrel_sql/client/session/properties/SessionPropertiesTest.java 2010-11-23 23:10:33 UTC (rev 6003)
@@ -322,5 +322,35 @@
classUnderTest.setShowResultsMetaData(true);
assertEquals(true, classUnderTest.getShowResultsMetaData());
}
+
+ @Test
+ public void testGetUseFetchSize() throws Exception {
+ classUnderTest.setSQLUseFetchSize(true);
+ assertEquals(true, classUnderTest.getSQLUseFetchSize());
+
+ classUnderTest.setSQLUseFetchSize(false);
+ assertEquals(false, classUnderTest.getSQLUseFetchSize());
+ }
+
+ @Test
+ public void testGetFetchSize() throws Exception {
+ classUnderTest.setSQLFetchSize(99);
+ assertEquals(99, classUnderTest.getSQLFetchSize());
+
+ // If the fetchSize = 0, then the it will be ignored by the Statement.
+ classUnderTest.setSQLFetchSize(0);
+ assertEquals(0, classUnderTest.getSQLFetchSize());
+ }
+
+ @Test
+ public void testSetFetchSizeFailure() throws Exception {
+ try {
+ classUnderTest.setSQLFetchSize(-1);
+ assertEquals("Using a negativ value for the FetchSize isn't allowed",false, true);
+
+ } catch (IllegalArgumentException e) {
+ assertEquals("FetchSize must be >= 0. fetchSize=-1",e.getMessage());
+ }
+ }
}
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2010-11-23 22:09:58 UTC (rev 6002)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2010-11-23 23:10:33 UTC (rev 6003)
@@ -12,7 +12,11 @@
Graph Plugin: Multiple tables can now be selected and moved simultanously
Thanks to Markus Schulz for the patch.
+New Session property to let SQuirreL set fetch size (call Statement.setFetchSize(int)).
+ See Session properties --> SQL tab.
+ Thanks to Stefan (wis775) for the patch
+
Bug-fixes:
Bug 3055859: Regular expressions did not work in find & replace dialog
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|