From af212b630a3e048081d9f97ef13146d4d779c9ac Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 11:40:44 +0000 Subject: [PATCH 01/12] Parameterize PreparedStatement fetch size. --- src/com/waratek/spiracle/init/SpiracleInit.java | 13 ++++++++++++- src/com/waratek/spiracle/sql/util/SelectUtil.java | 10 ++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/com/waratek/spiracle/init/SpiracleInit.java b/src/com/waratek/spiracle/init/SpiracleInit.java index a54b248..a5e56b3 100644 --- a/src/com/waratek/spiracle/init/SpiracleInit.java +++ b/src/com/waratek/spiracle/init/SpiracleInit.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; - import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; @@ -50,6 +49,7 @@ public void contextInitialized(ServletContextEvent arg0) { loadLog4jConfig(props); ComboPooledDataSource ds = getConnectionPool(props); setConnectionPool(application, ds); + setFetchSize(application, props); } private Properties loadProperties(ServletContext application) { @@ -113,4 +113,15 @@ private ComboPooledDataSource getConnectionPool(Properties props) { ds.setMaxPoolSize(maxPoolSize); return ds; } + + private void setFetchSize(ServletContext application, Properties props) { + int fetchSize = 0; + try { + fetchSize = Integer.parseInt(props.getProperty("jdbc.fetchsize")); + application.setAttribute("fetchSize", fetchSize); + logger.info("Set jdbc.fetchsize to (" + fetchSize + ")"); + } catch (NumberFormatException e) { + logger.error("jdbc.fetchsize not specified, default value set(10)."); + } + } } diff --git a/src/com/waratek/spiracle/sql/util/SelectUtil.java b/src/com/waratek/spiracle/sql/util/SelectUtil.java index 957b092..777e07a 100644 --- a/src/com/waratek/spiracle/sql/util/SelectUtil.java +++ b/src/com/waratek/spiracle/sql/util/SelectUtil.java @@ -38,7 +38,8 @@ public static void executeQuery(String sql, ServletContext application, HttpServ ServletOutputStream out = response.getOutputStream(); String connectionType = null; Connection con = null; - + int fetchSize = (Integer) application.getAttribute("fetchSize"); + TagUtil.printPageHead(out); TagUtil.printPageNavbar(out); TagUtil.printContentDiv(out); @@ -60,6 +61,7 @@ public static void executeQuery(String sql, ServletContext application, HttpServ logger.info(sql); PreparedStatement stmt = con.prepareStatement(sql); + stmt.setFetchSize(fetchSize); ResultSet rs = stmt.executeQuery(); writeToResponse(allResults, showOutput, out, rs); @@ -69,7 +71,7 @@ public static void executeQuery(String sql, ServletContext application, HttpServ con.close(); } catch(SQLException e) { if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) { - response.setStatus(550); + response.setStatus(550); } else { response.setStatus(500); } @@ -88,9 +90,9 @@ public static void executeQuery(String sql, ServletContext application, HttpServ con.close(); } catch (SQLException e1) { if(logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); + logger.debug(e1.getMessage(), e1); } else { - logger.error(e); + logger.error(e1); } } From fcc236d017ffae6ecc9fc0ac59bf07c78cb2ceef Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 11:50:57 +0000 Subject: [PATCH 02/12] Move Oracle targeted servlets to new package. --- WebContent/conf/Spiracle.properties | 8 +++++--- .../spiracle/sql/{ => oracle}/servlet/Delete_User.java | 2 +- .../sql/{ => oracle}/servlet/Get_Full_Outer_Join.java | 2 +- .../sql/{ => oracle}/servlet/Get_Implicit_Join.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Get_Union.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Get_int.java | 2 +- .../sql/{ => oracle}/servlet/Get_int_groupby.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Get_int_having.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Get_int_inline.java | 2 +- .../sql/{ => oracle}/servlet/Get_int_no_quote.java | 2 +- .../sql/{ => oracle}/servlet/Get_int_nooutput.java | 2 +- .../sql/{ => oracle}/servlet/Get_int_orderby.java | 2 +- .../sql/{ => oracle}/servlet/Get_int_partialunion.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Get_string.java | 2 +- .../sql/{ => oracle}/servlet/Get_string_constructor.java | 2 +- .../sql/{ => oracle}/servlet/Get_string_no_quote.java | 2 +- .../servlet/Get_string_no_quote_sanitised.java | 2 +- .../sql/{ => oracle}/servlet/Get_string_sanitised.java | 2 +- .../sql/{ => oracle}/servlet/Implicit_Join_Namespace.java | 2 +- .../sql/{ => oracle}/servlet/Insert_Raw_Text.java | 2 +- .../{ => oracle}/servlet/Insert_Raw_Text_Sanitised.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Insert_User.java | 2 +- .../spiracle/sql/{ => oracle}/servlet/Update_User.java | 2 +- 23 files changed, 27 insertions(+), 25 deletions(-) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Delete_User.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_Full_Outer_Join.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_Implicit_Join.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_Union.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_groupby.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_having.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_inline.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_no_quote.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_nooutput.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_orderby.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_int_partialunion.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_string.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_string_constructor.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_string_no_quote.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_string_no_quote_sanitised.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Get_string_sanitised.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Implicit_Join_Namespace.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Insert_Raw_Text.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Insert_Raw_Text_Sanitised.java (97%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Insert_User.java (98%) rename src/com/waratek/spiracle/sql/{ => oracle}/servlet/Update_User.java (98%) diff --git a/WebContent/conf/Spiracle.properties b/WebContent/conf/Spiracle.properties index 0c74292..83a6e16 100644 --- a/WebContent/conf/Spiracle.properties +++ b/WebContent/conf/Spiracle.properties @@ -1,7 +1,7 @@ -c3p0.classname=oracle.jdbc.driver.OracleDriver -c3p0.url=jdbc:oracle:thin:@localhost:1521:XE +c3p0.classname=com.mysql.jdbc.Driver +c3p0.url=jdbc:mysql://phy05:3306/test c3p0.username=test -c3p0.password=test +c3p0.password=5{Ck&zJi c3p0.maxPoolSize=50 java.classname=oracle.jdbc.driver.OracleDriver @@ -9,6 +9,8 @@ java.url=jdbc:oracle:thin:@localhost:1521:XE java.username=test java.password=test +jdbc.fetchsize=25 + spring.path=/path/to/spring-context.xml application.loggingEnabled=True diff --git a/src/com/waratek/spiracle/sql/servlet/Delete_User.java b/src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Delete_User.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java index 8acedd2..fa29117 100644 --- a/src/com/waratek/spiracle/sql/servlet/Delete_User.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_Full_Outer_Join.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_Full_Outer_Join.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java index eefabed..a3f5b43 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_Full_Outer_Join.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_Implicit_Join.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_Implicit_Join.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java index 6b8ded1..e1eb97d 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_Implicit_Join.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_Union.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_Union.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java index de53961..2db2a7e 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_Union.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java index 5d70871..dcce02b 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_groupby.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_groupby.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java index 0ec3cdf..4ad93d9 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_groupby.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_having.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_having.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java index 7e66898..e499469 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_having.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_inline.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_inline.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java index 2bba4fd..b8c5906 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_inline.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_no_quote.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_no_quote.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java index df71610..dd7558c 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_no_quote.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_nooutput.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_nooutput.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java index 76a3257..62fc870 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_nooutput.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_orderby.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_orderby.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java index cca73d5..872b0a9 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_orderby.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_int_partialunion.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_int_partialunion.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java index 3c73301..49ac0cb 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_int_partialunion.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_string.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_string.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java index e3a3f96..46ded75 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_string.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_string_constructor.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Get_string_constructor.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java index 25f823c..fc341e4 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_string_constructor.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_string_no_quote.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Get_string_no_quote.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java index bbb684d..7b4e1f8 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_string_no_quote.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_string_no_quote_sanitised.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Get_string_no_quote_sanitised.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java index fe9f4d7..115d460 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_string_no_quote_sanitised.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Get_string_sanitised.java b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Get_string_sanitised.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java index d647b61..b7ae187 100644 --- a/src/com/waratek/spiracle/sql/servlet/Get_string_sanitised.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Implicit_Join_Namespace.java b/src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Implicit_Join_Namespace.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java index 5e40084..59a2fe8 100644 --- a/src/com/waratek/spiracle/sql/servlet/Implicit_Join_Namespace.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text.java b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java index 3b73b27..8e94c87 100644 --- a/src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text_Sanitised.java b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text_Sanitised.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java index 0dd2279..0366c24 100644 --- a/src/com/waratek/spiracle/sql/servlet/Insert_Raw_Text_Sanitised.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Insert_User.java b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Insert_User.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java index 504b614..9b3203a 100644 --- a/src/com/waratek/spiracle/sql/servlet/Insert_User.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/servlet/Update_User.java b/src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/servlet/Update_User.java rename to src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java index b12b3dd..6249133 100644 --- a/src/com/waratek/spiracle/sql/servlet/Update_User.java +++ b/src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.servlet; +package com.waratek.spiracle.sql.oracle.servlet; import java.io.IOException; import java.util.ArrayList; From 80263f0623cd434dad8e4c4995264019a0e46116 Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 11:53:33 +0000 Subject: [PATCH 03/12] Fix package name. --- .../sql/{oracle/servlet => servlet/oracle}/Delete_User.java | 2 +- .../{oracle/servlet => servlet/oracle}/Get_Full_Outer_Join.java | 2 +- .../{oracle/servlet => servlet/oracle}/Get_Implicit_Join.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_Union.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_int.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_int_groupby.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_int_having.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_int_inline.java | 2 +- .../{oracle/servlet => servlet/oracle}/Get_int_no_quote.java | 2 +- .../{oracle/servlet => servlet/oracle}/Get_int_nooutput.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_int_orderby.java | 2 +- .../servlet => servlet/oracle}/Get_int_partialunion.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Get_string.java | 2 +- .../servlet => servlet/oracle}/Get_string_constructor.java | 2 +- .../{oracle/servlet => servlet/oracle}/Get_string_no_quote.java | 2 +- .../oracle}/Get_string_no_quote_sanitised.java | 2 +- .../servlet => servlet/oracle}/Get_string_sanitised.java | 2 +- .../servlet => servlet/oracle}/Implicit_Join_Namespace.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Insert_Raw_Text.java | 2 +- .../servlet => servlet/oracle}/Insert_Raw_Text_Sanitised.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Insert_User.java | 2 +- .../sql/{oracle/servlet => servlet/oracle}/Update_User.java | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Delete_User.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_Full_Outer_Join.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_Implicit_Join.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_Union.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_groupby.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_having.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_inline.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_no_quote.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_nooutput.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_orderby.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_int_partialunion.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_string.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_string_constructor.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_string_no_quote.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_string_no_quote_sanitised.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Get_string_sanitised.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Implicit_Join_Namespace.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Insert_Raw_Text.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Insert_Raw_Text_Sanitised.java (97%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Insert_User.java (98%) rename src/com/waratek/spiracle/sql/{oracle/servlet => servlet/oracle}/Update_User.java (98%) diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java b/src/com/waratek/spiracle/sql/servlet/oracle/Delete_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Delete_User.java index fa29117..0330c76 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Delete_User.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Delete_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Full_Outer_Join.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_Full_Outer_Join.java index a3f5b43..591ca96 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Full_Outer_Join.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Full_Outer_Join.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Implicit_Join.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_Implicit_Join.java index e1eb97d..a2d44a5 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Implicit_Join.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Implicit_Join.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Union.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_Union.java index 2db2a7e..deed032 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_Union.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_Union.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int.java index dcce02b..193dbdc 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_groupby.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_groupby.java index 4ad93d9..435d59a 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_groupby.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_groupby.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_having.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_having.java index e499469..2f1c7f3 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_having.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_having.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_inline.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_inline.java index b8c5906..77afb02 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_inline.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_inline.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_no_quote.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_no_quote.java index dd7558c..67be8cf 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_no_quote.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_no_quote.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_nooutput.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_nooutput.java index 62fc870..3309912 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_nooutput.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_nooutput.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_orderby.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_orderby.java index 872b0a9..2fb93dc 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_orderby.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_orderby.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_partialunion.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_int_partialunion.java index 49ac0cb..288130d 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_int_partialunion.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_int_partialunion.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_string.java index 46ded75..c7a0d34 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_constructor.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_string_constructor.java index fc341e4..9d18c7d 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_constructor.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_constructor.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote.java index 7b4e1f8..a0a8fab 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote_sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote_sanitised.java index 115d460..9466c9e 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_no_quote_sanitised.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_no_quote_sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Get_string_sanitised.java index b7ae187..48cd47d 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Get_string_sanitised.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Get_string_sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java b/src/com/waratek/spiracle/sql/servlet/oracle/Implicit_Join_Namespace.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Implicit_Join_Namespace.java index 59a2fe8..770bf08 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Implicit_Join_Namespace.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Implicit_Join_Namespace.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text.java index 8e94c87..bfa465b 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text_Sanitised.java similarity index 97% rename from src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text_Sanitised.java index 0366c24..8c71cf6 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_Raw_Text_Sanitised.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_Raw_Text_Sanitised.java @@ -1,4 +1,4 @@ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Insert_User.java index 9b3203a..46954df 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Insert_User.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Insert_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; diff --git a/src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java b/src/com/waratek/spiracle/sql/servlet/oracle/Update_User.java similarity index 98% rename from src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java rename to src/com/waratek/spiracle/sql/servlet/oracle/Update_User.java index 6249133..7319c01 100644 --- a/src/com/waratek/spiracle/sql/oracle/servlet/Update_User.java +++ b/src/com/waratek/spiracle/sql/servlet/oracle/Update_User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.waratek.spiracle.sql.oracle.servlet; +package com.waratek.spiracle.sql.servlet.oracle; import java.io.IOException; import java.util.ArrayList; From 91850bdb6e7364fbee2dcfae07465f07041f8bac Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 14:15:26 +0000 Subject: [PATCH 04/12] Added appserver information log messages. --- src/com/waratek/spiracle/init/SpiracleInit.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/waratek/spiracle/init/SpiracleInit.java b/src/com/waratek/spiracle/init/SpiracleInit.java index a5e56b3..bc709c3 100644 --- a/src/com/waratek/spiracle/init/SpiracleInit.java +++ b/src/com/waratek/spiracle/init/SpiracleInit.java @@ -47,6 +47,7 @@ public void contextInitialized(ServletContextEvent arg0) { ServletContext application = arg0.getServletContext(); Properties props = loadProperties(application); loadLog4jConfig(props); + logServerInfo(application); ComboPooledDataSource ds = getConnectionPool(props); setConnectionPool(application, ds); setFetchSize(application, props); @@ -124,4 +125,9 @@ private void setFetchSize(ServletContext application, Properties props) { logger.error("jdbc.fetchsize not specified, default value set(10)."); } } + + void logServerInfo(ServletContext application) { + logger.info("Application Server Name: " + application.getServerInfo()); + logger.info("Application Context Path:" + application.getRealPath("")); + } } From f308725b5b9165b86e4725252ec752211f01347c Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 14:55:23 +0000 Subject: [PATCH 05/12] Organise imports, cleanup whitespace. --- .../waratek/spiracle/sql/util/UpdateUtil.java | 116 +++++++++--------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/src/com/waratek/spiracle/sql/util/UpdateUtil.java b/src/com/waratek/spiracle/sql/util/UpdateUtil.java index 6f6f182..31d35ab 100644 --- a/src/com/waratek/spiracle/sql/util/UpdateUtil.java +++ b/src/com/waratek/spiracle/sql/util/UpdateUtil.java @@ -27,74 +27,72 @@ import org.apache.log4j.Logger; -import com.waratek.spiracle.init.SpiracleInit; - public class UpdateUtil { private static final Logger logger = Logger.getLogger(UpdateUtil.class); - public static void executeUpdate(String sql, ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException{ - response.setHeader("Content-Type", "text/html;charset=UTF-8"); - ServletOutputStream out = response.getOutputStream(); - String connectionType = null; - Connection con = null; + public static void executeUpdate(String sql, ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException{ + response.setHeader("Content-Type", "text/html;charset=UTF-8"); + ServletOutputStream out = response.getOutputStream(); + String connectionType = null; + Connection con = null; + + TagUtil.printPageHead(out); + TagUtil.printPageNavbar(out); + TagUtil.printContentDiv(out); + + try { + //Checking if connectionType is not, defaulting it to c3p0 if not set. + if(request.getParameter("connectionType") == null) { + connectionType = "c3p0"; + } else { + connectionType = request.getParameter("connectionType"); + } + con = ConnectionUtil.getConnection(application, connectionType); + out.println("
"); + out.println("

SQL Query:

"); + out.println("
");
+			out.println(sql);
+			out.println("
"); - TagUtil.printPageHead(out); - TagUtil.printPageNavbar(out); - TagUtil.printContentDiv(out); - - try { - //Checking if connectionType is not, defaulting it to c3p0 if not set. - if(request.getParameter("connectionType") == null) { - connectionType = "c3p0"; - } else { - connectionType = request.getParameter("connectionType"); - } - con = ConnectionUtil.getConnection(application, connectionType); - out.println("
"); - out.println("

SQL Query:

"); - out.println("
");
-            out.println(sql);
-            out.println("
"); + logger.info(sql); - logger.info(sql); + PreparedStatement stmt = con.prepareStatement(sql); + int result = stmt.executeUpdate(); + out.println("

Altered Rows:

"); + out.print("
" + result + "
"); + TagUtil.printPageFooter(out); + out.close(); + stmt.close(); + con.close(); - PreparedStatement stmt = con.prepareStatement(sql); - int result = stmt.executeUpdate(); - out.println("

Altered Rows:

"); - out.print("
" + result + "
"); - TagUtil.printPageFooter(out); - out.close(); - stmt.close(); - con.close(); - - } catch(SQLException e) { - if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) { - response.setStatus(550); - } else { - response.setStatus(500); - } - out.println("
"); - out.println("SQLException: " + e.getMessage() + "
"); + } catch(SQLException e) { + if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) { + response.setStatus(550); + } else { + response.setStatus(500); + } + out.println("
"); + out.println("SQLException: " + e.getMessage() + "
"); if(logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } else { logger.error(e); } - while((e = e.getNextException()) != null) { - out.println(e.getMessage() + "
"); - } - try { - con.rollback(); - con.close(); - } catch (SQLException e1) { - if(logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); - } else { - logger.error(e); - } - } - out.println("
"); - TagUtil.printPageFooter(out); - } - } + while((e = e.getNextException()) != null) { + out.println(e.getMessage() + "
"); + } + try { + con.rollback(); + con.close(); + } catch (SQLException e1) { + if(logger.isDebugEnabled()) { + logger.debug(e.getMessage(), e); + } else { + logger.error(e); + } + } + out.println("
"); + TagUtil.printPageFooter(out); + } + } } From 7e88f9795506d6beebbda9dc1f49adb1eaeca5c0 Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 14:56:33 +0000 Subject: [PATCH 06/12] Fix log output incorrectly logging exception message from outer scope. --- src/com/waratek/spiracle/sql/util/UpdateUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/waratek/spiracle/sql/util/UpdateUtil.java b/src/com/waratek/spiracle/sql/util/UpdateUtil.java index 31d35ab..1f6f1ae 100644 --- a/src/com/waratek/spiracle/sql/util/UpdateUtil.java +++ b/src/com/waratek/spiracle/sql/util/UpdateUtil.java @@ -86,9 +86,9 @@ public static void executeUpdate(String sql, ServletContext application, HttpSer con.close(); } catch (SQLException e1) { if(logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); + logger.debug(e1.getMessage(), e); } else { - logger.error(e); + logger.error(e1); } } out.println("
"); From 49840a292d26f93ac0eadeb4f6cc7a33eef15039 Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 15:13:42 +0000 Subject: [PATCH 07/12] Trivial method extraction refactor. --- .../waratek/spiracle/file/FileServlet.java | 155 ++++++++++-------- 1 file changed, 83 insertions(+), 72 deletions(-) diff --git a/src/com/waratek/spiracle/file/FileServlet.java b/src/com/waratek/spiracle/file/FileServlet.java index 2d7ecbe..022507b 100644 --- a/src/com/waratek/spiracle/file/FileServlet.java +++ b/src/com/waratek/spiracle/file/FileServlet.java @@ -36,79 +36,90 @@ @WebServlet("/FileServlet") public class FileServlet extends HttpServlet { private static final Logger logger = Logger.getLogger(FileServlet.class); - private static final long serialVersionUID = 1L; - - /** - * @see HttpServlet#HttpServlet() - */ - public FileServlet() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } - - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } - - private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(); - - String method = request.getParameter("fileArg"); - String path = request.getParameter("filePath"); - String textData = request.getParameter("fileText"); - - if(method.equals("read")) { - session.setAttribute("fileContents", readFile(path)); - - } else if(method.equals("write")) { - File f = new File(path); - FileWriter fw = new FileWriter(f); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(textData); - bw.close(); - fw.close(); - - session.setAttribute("fileContents", readFile(path)); - - } else if(method.equals("delete")) { - File f = new File(path); - f.delete(); - session.setAttribute("fileContents", ""); - } + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public FileServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } + + private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { + HttpSession session = request.getSession(); + + String method = request.getParameter("fileArg"); + String path = request.getParameter("filePath"); + String textData = request.getParameter("fileText"); + + if(method.equals("read")) { + read(session, path); + } else if(method.equals("write")) { + write(session, path, textData); + } else if(method.equals("delete")) { + delete(session, path); + } logger.info(method + " " + path + " " + textData); - response.sendRedirect("file.jsp"); - } - - private String readFile(String pathname) { - try { - File file = new File(pathname); - StringBuilder fileContents = new StringBuilder((int)file.length()); - Scanner scanner = new Scanner(file); - String lineSeparator = System.getProperty("line.separator"); - - try { - while(scanner.hasNextLine()) { - fileContents.append(scanner.nextLine() + lineSeparator); - } - return fileContents.toString(); - } finally { - scanner.close(); - } - } catch (IOException e) { - e.printStackTrace(); - return e.getMessage(); - } - } + response.sendRedirect("file.jsp"); + } + + private void delete(HttpSession session, String path) { + File f = new File(path); + f.delete(); + session.setAttribute("fileContents", ""); + } + + private void read(HttpSession session, String path) { + session.setAttribute("fileContents", readFile(path)); + } + + private void write(HttpSession session, String path, String textData) + throws IOException { + File f = new File(path); + FileWriter fw = new FileWriter(f); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(textData); + bw.close(); + fw.close(); + + read(session, path); + } + + private String readFile(String pathname) { + try { + File file = new File(pathname); + StringBuilder fileContents = new StringBuilder((int)file.length()); + Scanner scanner = new Scanner(file); + String lineSeparator = System.getProperty("line.separator"); + + try { + while(scanner.hasNextLine()) { + fileContents.append(scanner.nextLine() + lineSeparator); + } + return fileContents.toString(); + } finally { + scanner.close(); + } + } catch (IOException e) { + e.printStackTrace(); + return e.getMessage(); + } + } } From 10eed96529495df0368f81881c10c390227fe4ef Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 15:14:35 +0000 Subject: [PATCH 08/12] Trivial whitespace fix. --- src/com/waratek/spiracle/init/SpiracleInit.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/waratek/spiracle/init/SpiracleInit.java b/src/com/waratek/spiracle/init/SpiracleInit.java index bc709c3..008088f 100644 --- a/src/com/waratek/spiracle/init/SpiracleInit.java +++ b/src/com/waratek/spiracle/init/SpiracleInit.java @@ -114,7 +114,7 @@ private ComboPooledDataSource getConnectionPool(Properties props) { ds.setMaxPoolSize(maxPoolSize); return ds; } - + private void setFetchSize(ServletContext application, Properties props) { int fetchSize = 0; try { @@ -125,9 +125,9 @@ private void setFetchSize(ServletContext application, Properties props) { logger.error("jdbc.fetchsize not specified, default value set(10)."); } } - + void logServerInfo(ServletContext application) { logger.info("Application Server Name: " + application.getServerInfo()); - logger.info("Application Context Path:" + application.getRealPath("")); + logger.info("Application Context Path:" + application.getRealPath("")); } } From 360874171a8f1302a59d264898e7d5db2d5f4f4d Mon Sep 17 00:00:00 2001 From: skenny Date: Thu, 29 Jan 2015 17:19:54 +0000 Subject: [PATCH 09/12] Trivial whitespace fixes. --- .../spiracle/network/ServerSocketServlet.java | 108 +++++------ .../spiracle/network/ServerSocketThread.java | 56 +++--- .../spiracle/network/SocketServlet.java | 146 +++++++------- .../waratek/spiracle/network/UrlServlet.java | 99 +++++----- .../sql/c3p0/CreateC3p0Connection.java | 183 +++++++++--------- .../sql/java/CreateJavaConnection.java | 147 +++++++------- .../sql/servlet/util/ParameterNullFix.java | 28 +-- .../sql/spring/CreateSpringContext.java | 96 +++++---- .../spiracle/sql/util/ConnectionUtil.java | 34 ++-- .../waratek/spiracle/sql/util/SelectUtil.java | 8 +- .../waratek/spiracle/sql/util/TagUtil.java | 32 +-- 11 files changed, 467 insertions(+), 470 deletions(-) diff --git a/src/com/waratek/spiracle/network/ServerSocketServlet.java b/src/com/waratek/spiracle/network/ServerSocketServlet.java index 205e86d..5d8d12b 100644 --- a/src/com/waratek/spiracle/network/ServerSocketServlet.java +++ b/src/com/waratek/spiracle/network/ServerSocketServlet.java @@ -32,62 +32,62 @@ */ @WebServlet("/ServerSocketServlet") public class ServerSocketServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private static ServerSocket ss; - private static Socket s; - - /** - * @see HttpServlet#HttpServlet() - */ - public ServerSocketServlet() { - super(); - // TODO Auto-generated constructor stub - } + private static final long serialVersionUID = 1L; + private static ServerSocket ss; + private static Socket s; - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } + /** + * @see HttpServlet#HttpServlet() + */ + public ServerSocketServlet() { + super(); + // TODO Auto-generated constructor stub + } - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } - private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { - if(ss != null && s != null) { - ss.close(); - s.close(); - } - - HttpSession session = request.getSession(); - try { - String addr = request.getParameter("hostname"); - int port = Integer.parseInt(request.getParameter("port")); - if(addr == null) { - ss = new ServerSocket(port); - } else { - ss = new ServerSocket(); - ss.bind(new InetSocketAddress(addr, port)); - } - ss.setSoTimeout(20000); - s = ss.accept(); - session.setAttribute("serverSocketInfo", ss.toString()); - response.sendRedirect("network.jsp"); - - } catch (Throwable e) { - if(ss != null) { - ss.close(); - s.close(); - } - e.printStackTrace(); - session.setAttribute("serverSocketInfo", e.getMessage()); - response.sendRedirect("network.jsp"); - } - } + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } + + private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { + if(ss != null && s != null) { + ss.close(); + s.close(); + } + + HttpSession session = request.getSession(); + try { + String addr = request.getParameter("hostname"); + int port = Integer.parseInt(request.getParameter("port")); + if(addr == null) { + ss = new ServerSocket(port); + } else { + ss = new ServerSocket(); + ss.bind(new InetSocketAddress(addr, port)); + } + ss.setSoTimeout(20000); + s = ss.accept(); + session.setAttribute("serverSocketInfo", ss.toString()); + response.sendRedirect("network.jsp"); + + } catch (Throwable e) { + if(ss != null) { + ss.close(); + s.close(); + } + e.printStackTrace(); + session.setAttribute("serverSocketInfo", e.getMessage()); + response.sendRedirect("network.jsp"); + } + } } diff --git a/src/com/waratek/spiracle/network/ServerSocketThread.java b/src/com/waratek/spiracle/network/ServerSocketThread.java index c284066..9ada953 100644 --- a/src/com/waratek/spiracle/network/ServerSocketThread.java +++ b/src/com/waratek/spiracle/network/ServerSocketThread.java @@ -21,34 +21,34 @@ public class ServerSocketThread extends Thread { - private ServerSocket s; - public ServerSocketThread(int port) throws IOException { - super(); - s = new ServerSocket(port); - } + private ServerSocket s; + public ServerSocketThread(int port) throws IOException { + super(); + s = new ServerSocket(port); + } - public String toString() { - return s.toString(); - } + public String toString() { + return s.toString(); + } - public void run() { - Socket sock = null; - do { - try { - sock = s.accept(); - while(!this.isInterrupted()) { - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while(!this.isInterrupted()); - try { - sock.close(); - s.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + public void run() { + Socket sock = null; + do { + try { + sock = s.accept(); + while(!this.isInterrupted()) { + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while(!this.isInterrupted()); + try { + sock.close(); + s.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/src/com/waratek/spiracle/network/SocketServlet.java b/src/com/waratek/spiracle/network/SocketServlet.java index a4829c8..e49803a 100644 --- a/src/com/waratek/spiracle/network/SocketServlet.java +++ b/src/com/waratek/spiracle/network/SocketServlet.java @@ -31,78 +31,78 @@ */ @WebServlet("/SocketServlet") public class SocketServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private static Socket s; - - /** - * @see HttpServlet#HttpServlet() - */ - public SocketServlet() { - super(); - } - - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } - - /** - * @throws IOException - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } - - private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { - if(s != null) { - s.close(); - } - - HttpSession session = request.getSession(); - try { - String bindHost = request.getParameter("bindHost"); - String remoteHost = request.getParameter("remoteHost"); - - Integer bindPort = 0; - Integer remotePort = 0; - - String bindPortRaw = request.getParameter("bindPort"); - String remotePortRaw = request.getParameter("remotePort"); - - if(bindPortRaw.length() > 0) { - bindPort = Integer.parseInt((String)bindPortRaw); - } else { - bindPort = null; - } - if(remotePortRaw.length() > 0) { - remotePort = Integer.parseInt((String)remotePortRaw); - } else { - remotePort = null; - } - - s = new Socket(); - if(bindHost.length() == 0 || bindHost.length() == 0) { - s.bind(null); - } else { - s.bind(new InetSocketAddress(bindHost, bindPort.intValue())); - } - - s.connect(new InetSocketAddress(remoteHost, remotePort.intValue())); - session.setAttribute("socketInfo", s.toString()); - - response.sendRedirect("network.jsp"); - } catch (Throwable e) { - if(s != null) { - s.close(); - } - e.printStackTrace(); - session.setAttribute("socketInfo", e.getMessage()); - response.sendRedirect("network.jsp"); - - } - } + private static final long serialVersionUID = 1L; + private static Socket s; + + /** + * @see HttpServlet#HttpServlet() + */ + public SocketServlet() { + super(); + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } + + /** + * @throws IOException + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } + + private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { + if(s != null) { + s.close(); + } + + HttpSession session = request.getSession(); + try { + String bindHost = request.getParameter("bindHost"); + String remoteHost = request.getParameter("remoteHost"); + + Integer bindPort = 0; + Integer remotePort = 0; + + String bindPortRaw = request.getParameter("bindPort"); + String remotePortRaw = request.getParameter("remotePort"); + + if(bindPortRaw.length() > 0) { + bindPort = Integer.parseInt((String)bindPortRaw); + } else { + bindPort = null; + } + if(remotePortRaw.length() > 0) { + remotePort = Integer.parseInt((String)remotePortRaw); + } else { + remotePort = null; + } + + s = new Socket(); + if(bindHost.length() == 0 || bindHost.length() == 0) { + s.bind(null); + } else { + s.bind(new InetSocketAddress(bindHost, bindPort.intValue())); + } + + s.connect(new InetSocketAddress(remoteHost, remotePort.intValue())); + session.setAttribute("socketInfo", s.toString()); + + response.sendRedirect("network.jsp"); + } catch (Throwable e) { + if(s != null) { + s.close(); + } + e.printStackTrace(); + session.setAttribute("socketInfo", e.getMessage()); + response.sendRedirect("network.jsp"); + + } + } } diff --git a/src/com/waratek/spiracle/network/UrlServlet.java b/src/com/waratek/spiracle/network/UrlServlet.java index cd60fc5..8d14057 100644 --- a/src/com/waratek/spiracle/network/UrlServlet.java +++ b/src/com/waratek/spiracle/network/UrlServlet.java @@ -34,61 +34,60 @@ */ @WebServlet("/UrlServlet") public class UrlServlet extends HttpServlet { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * @see HttpServlet#HttpServlet() - */ - public UrlServlet() { - super(); - // TODO Auto-generated constructor stub - } + /** + * @see HttpServlet#HttpServlet() + */ + public UrlServlet() { + super(); + // TODO Auto-generated constructor stub + } - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - executeRequest(request, response); - } + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + executeRequest(request, response); + } - private void executeRequest(HttpServletRequest request, - HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(); - String urlPath = request.getParameter("urlPath"); + private void executeRequest(HttpServletRequest request, + HttpServletResponse response) throws IOException { + HttpSession session = request.getSession(); + String urlPath = request.getParameter("urlPath"); - session.setAttribute("urlContents", readUrl(urlPath)); - response.sendRedirect("network.jsp"); - } + session.setAttribute("urlContents", readUrl(urlPath)); + response.sendRedirect("network.jsp"); + } - private String readUrl(String pathname) throws IOException { - try { - URLConnection con = new URL(pathname).openConnection(); - Scanner scanner = new Scanner(con.getInputStream()); - StringBuilder fileContents = new StringBuilder(); - String lineSeparator = System.getProperty("line.separator"); + private String readUrl(String pathname) throws IOException { + try { + URLConnection con = new URL(pathname).openConnection(); + Scanner scanner = new Scanner(con.getInputStream()); + StringBuilder fileContents = new StringBuilder(); + String lineSeparator = System.getProperty("line.separator"); - try { - while(scanner.hasNextLine()) { - fileContents.append(scanner.nextLine() + lineSeparator); - } - return fileContents.toString(); - } finally { - scanner.close(); - } - } catch (MalformedURLException e) { - e.printStackTrace(); - return "Please enter a valid URL"; - } catch (UnknownHostException e) { - e.printStackTrace(); - return "Please enter a valid URL"; - } - - } + try { + while(scanner.hasNextLine()) { + fileContents.append(scanner.nextLine() + lineSeparator); + } + return fileContents.toString(); + } finally { + scanner.close(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + return "Please enter a valid URL"; + } catch (UnknownHostException e) { + e.printStackTrace(); + return "Please enter a valid URL"; + } + } } diff --git a/src/com/waratek/spiracle/sql/c3p0/CreateC3p0Connection.java b/src/com/waratek/spiracle/sql/c3p0/CreateC3p0Connection.java index dd869e6..f8439b8 100644 --- a/src/com/waratek/spiracle/sql/c3p0/CreateC3p0Connection.java +++ b/src/com/waratek/spiracle/sql/c3p0/CreateC3p0Connection.java @@ -36,96 +36,95 @@ */ @WebServlet("/CreateC3p0Connection") public class CreateC3p0Connection extends HttpServlet { - private static final long serialVersionUID = 1L; - - private String jdbcDriver; - private String url; - private String username; - private String password; - private int maxPoolSize; - - /** - * @see HttpServlet#HttpServlet() - */ - public CreateC3p0Connection() { - super(); - // TODO Auto-generated constructor stub - } - - public void init() { - ServletContext application = this.getServletConfig().getServletContext(); - InputStream propStream = application.getResourceAsStream("conf/Spiracle.properties"); - Properties prop = new Properties(); - try { - prop.load(propStream); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - jdbcDriver = prop.getProperty("c3p0.classname"); - url = prop.getProperty("c3p0.url"); - username = prop.getProperty("c3p0.username"); - password = prop.getProperty("c3p0.password"); - try { - maxPoolSize = Integer.parseInt(prop.getProperty("c3p0.maxPoolSize")); - } catch (NumberFormatException e) { - maxPoolSize = 25; - } - - } - - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - setupConnectionPool(request, response); - } - - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - setupConnectionPool(request, response); - } - - private void setupConnectionPool(HttpServletRequest request, HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(); - if(request.getParameter("connectionUrl") == null || request.getParameter("username") == null || request.getParameter("password") == null) { - - } else { - url = request.getParameter("connectionUrl"); - username = request.getParameter("username"); - password = request.getParameter("password"); - } - - try { - ComboPooledDataSource ds = createConnectionPool(); - - ServletContext application = this.getServletConfig().getServletContext(); - application.setAttribute("connectionPool", ds); - application.setAttribute("connectionData", ds.toString()); - response.sendRedirect("sql.jsp"); - } catch (PropertyVetoException e) { - e.printStackTrace(); - session.setAttribute("error", e.getMessage()); - response.sendRedirect("sql.jsp"); - } - } - - private ComboPooledDataSource createConnectionPool() throws PropertyVetoException { - ComboPooledDataSource ds = new ComboPooledDataSource(); - - ds.setDriverClass(jdbcDriver); - ds.setJdbcUrl(url); - ds.setUser(username); - ds.setPassword(password); - ds.setMinPoolSize(5); - ds.setAcquireIncrement(5); - ds.setMaxPoolSize(maxPoolSize); - - return ds; - } + private static final long serialVersionUID = 1L; + + private String jdbcDriver; + private String url; + private String username; + private String password; + private int maxPoolSize; + + /** + * @see HttpServlet#HttpServlet() + */ + public CreateC3p0Connection() { + super(); + // TODO Auto-generated constructor stub + } + + public void init() { + ServletContext application = this.getServletConfig().getServletContext(); + InputStream propStream = application.getResourceAsStream("conf/Spiracle.properties"); + Properties prop = new Properties(); + try { + prop.load(propStream); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + jdbcDriver = prop.getProperty("c3p0.classname"); + url = prop.getProperty("c3p0.url"); + username = prop.getProperty("c3p0.username"); + password = prop.getProperty("c3p0.password"); + try { + maxPoolSize = Integer.parseInt(prop.getProperty("c3p0.maxPoolSize")); + } catch (NumberFormatException e) { + maxPoolSize = 25; + } + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + setupConnectionPool(request, response); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + setupConnectionPool(request, response); + } + + private void setupConnectionPool(HttpServletRequest request, HttpServletResponse response) throws IOException { + HttpSession session = request.getSession(); + if(request.getParameter("connectionUrl") == null || request.getParameter("username") == null || request.getParameter("password") == null) { + + } else { + url = request.getParameter("connectionUrl"); + username = request.getParameter("username"); + password = request.getParameter("password"); + } + + try { + ComboPooledDataSource ds = createConnectionPool(); + + ServletContext application = this.getServletConfig().getServletContext(); + application.setAttribute("connectionPool", ds); + application.setAttribute("connectionData", ds.toString()); + response.sendRedirect("sql.jsp"); + } catch (PropertyVetoException e) { + e.printStackTrace(); + session.setAttribute("error", e.getMessage()); + response.sendRedirect("sql.jsp"); + } + } + + private ComboPooledDataSource createConnectionPool() throws PropertyVetoException { + ComboPooledDataSource ds = new ComboPooledDataSource(); + + ds.setDriverClass(jdbcDriver); + ds.setJdbcUrl(url); + ds.setUser(username); + ds.setPassword(password); + ds.setMinPoolSize(5); + ds.setAcquireIncrement(5); + ds.setMaxPoolSize(maxPoolSize); + + return ds; + } } diff --git a/src/com/waratek/spiracle/sql/java/CreateJavaConnection.java b/src/com/waratek/spiracle/sql/java/CreateJavaConnection.java index 56c380a..81c7d73 100644 --- a/src/com/waratek/spiracle/sql/java/CreateJavaConnection.java +++ b/src/com/waratek/spiracle/sql/java/CreateJavaConnection.java @@ -36,82 +36,83 @@ */ @WebServlet("/CreateJavaConnection") public class CreateJavaConnection extends HttpServlet { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String jdbcDriver; - private String url; - private String username; - private String password; - /** - * @see HttpServlet#HttpServlet() - */ - public CreateJavaConnection() { - super(); - // TODO Auto-generated constructor stub - } - - public void init() { - ServletContext application = this.getServletConfig().getServletContext(); - InputStream propStream = application.getResourceAsStream("conf/Spriacle.properties"); - Properties prop = new Properties(); - try { - prop.load(propStream); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - jdbcDriver = prop.getProperty("java.classname"); - url = prop.getProperty("java.url"); - username = prop.getProperty("java.username"); - password = prop.getProperty("java.password"); - } + private String jdbcDriver; + private String url; + private String username; + private String password; - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - createConnection(request, response); - } + /** + * @see HttpServlet#HttpServlet() + */ + public CreateJavaConnection() { + super(); + // TODO Auto-generated constructor stub + } - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - createConnection(request, response); - } + public void init() { + ServletContext application = this.getServletConfig().getServletContext(); + InputStream propStream = application.getResourceAsStream("conf/Spriacle.properties"); + Properties prop = new Properties(); + try { + prop.load(propStream); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + jdbcDriver = prop.getProperty("java.classname"); + url = prop.getProperty("java.url"); + username = prop.getProperty("java.username"); + password = prop.getProperty("java.password"); + } - private void createConnection(HttpServletRequest request, HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(); - if(request.getParameter("connectionUrl") == null || request.getParameter("username") == null || request.getParameter("password") == null) { - - } else { - url = request.getParameter("connectionUrl"); - username = request.getParameter("username"); - password = request.getParameter("password"); - } - try { - Connection con = createJavaConnection(); - ServletContext application = this.getServletConfig().getServletContext(); - application.setAttribute("unpooledConnection", con); - session.setAttribute("connectionDataJava", con.toString()); - response.sendRedirect("sql.jsp"); - } catch(ClassNotFoundException e) { - e.printStackTrace(); - session.setAttribute("errorJava", e.getMessage()); - response.sendRedirect("sql.jsp"); - } catch(SQLException e) { - e.printStackTrace(); - session.setAttribute("errorJava", e.getMessage()); - response.sendRedirect("sql.jsp"); - } - } + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + createConnection(request, response); + } - private Connection createJavaConnection() throws ClassNotFoundException, SQLException { - Class.forName(jdbcDriver); - Connection con = DriverManager.getConnection(url, username, password); - return con; - } + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + createConnection(request, response); + } + + private void createConnection(HttpServletRequest request, HttpServletResponse response) throws IOException { + HttpSession session = request.getSession(); + if(request.getParameter("connectionUrl") == null || request.getParameter("username") == null || request.getParameter("password") == null) { + + } else { + url = request.getParameter("connectionUrl"); + username = request.getParameter("username"); + password = request.getParameter("password"); + } + try { + Connection con = createJavaConnection(); + ServletContext application = this.getServletConfig().getServletContext(); + application.setAttribute("unpooledConnection", con); + session.setAttribute("connectionDataJava", con.toString()); + response.sendRedirect("sql.jsp"); + } catch(ClassNotFoundException e) { + e.printStackTrace(); + session.setAttribute("errorJava", e.getMessage()); + response.sendRedirect("sql.jsp"); + } catch(SQLException e) { + e.printStackTrace(); + session.setAttribute("errorJava", e.getMessage()); + response.sendRedirect("sql.jsp"); + } + } + + private Connection createJavaConnection() throws ClassNotFoundException, SQLException { + Class.forName(jdbcDriver); + Connection con = DriverManager.getConnection(url, username, password); + return con; + } } diff --git a/src/com/waratek/spiracle/sql/servlet/util/ParameterNullFix.java b/src/com/waratek/spiracle/sql/servlet/util/ParameterNullFix.java index 5313104..ee26ddc 100644 --- a/src/com/waratek/spiracle/sql/servlet/util/ParameterNullFix.java +++ b/src/com/waratek/spiracle/sql/servlet/util/ParameterNullFix.java @@ -25,18 +25,18 @@ public class ParameterNullFix { private static final Logger logger = Logger.getLogger(ParameterNullFix.class); - - public static Map sanitizeNull(List inputList, HttpServletRequest request) { - Map outputMap= new HashMap(); - for(String item : inputList) { - String val = request.getParameter(item); - if(val == null) { - logger.info("Expected parameter [" + item + "] is null"); - outputMap.put(item, ""); - } else { - outputMap.put(item, val); - } - } - return outputMap; - } + + public static Map sanitizeNull(List inputList, HttpServletRequest request) { + Map outputMap= new HashMap(); + for(String item : inputList) { + String val = request.getParameter(item); + if(val == null) { + logger.info("Expected parameter {" + item + "} is null"); + outputMap.put(item, ""); + } else { + outputMap.put(item, val); + } + } + return outputMap; + } } diff --git a/src/com/waratek/spiracle/sql/spring/CreateSpringContext.java b/src/com/waratek/spiracle/sql/spring/CreateSpringContext.java index b1b505b..bd9c980 100644 --- a/src/com/waratek/spiracle/sql/spring/CreateSpringContext.java +++ b/src/com/waratek/spiracle/sql/spring/CreateSpringContext.java @@ -36,60 +36,58 @@ */ @WebServlet("/CreateSpringContext") public class CreateSpringContext extends HttpServlet { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String springContextPath; + private String springContextPath; - /** - * @see HttpServlet#HttpServlet() - */ - public CreateSpringContext() { - super(); - // TODO Auto-generated constructor stub - } + /** + * @see HttpServlet#HttpServlet() + */ + public CreateSpringContext() { + super(); + // TODO Auto-generated constructor stub + } - public void init() { - ServletContext application = this.getServletConfig().getServletContext(); - InputStream propStream = application.getResourceAsStream("conf/Spiracle.properties"); - Properties prop = new Properties(); - try { - prop.load(propStream); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - springContextPath = prop.getProperty("spring.path"); - } + public void init() { + ServletContext application = this.getServletConfig().getServletContext(); + InputStream propStream = application.getResourceAsStream("conf/Spiracle.properties"); + Properties prop = new Properties(); + try { + prop.load(propStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + springContextPath = prop.getProperty("spring.path"); + } - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - createSpringContext(request, response); - } + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + createSpringContext(request, response); + } - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - createSpringContext(request, response); - } + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + createSpringContext(request, response); + } - private void createSpringContext(HttpServletRequest request, HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(); - if(request.getParameter("filePath") == null) { - - } else { - springContextPath = request.getParameter("filePath").toString(); - } - ServletContext application = this.getServletConfig().getServletContext(); - ApplicationContext context = new FileSystemXmlApplicationContext("file:" + springContextPath); + private void createSpringContext(HttpServletRequest request, HttpServletResponse response) throws IOException { + HttpSession session = request.getSession(); + if(request.getParameter("filePath") == null) { - application.setAttribute("springContext", context); - session.setAttribute("springContextData", context.toString()); - response.sendRedirect("sql.jsp"); - } + } else { + springContextPath = request.getParameter("filePath").toString(); + } + ServletContext application = this.getServletConfig().getServletContext(); + ApplicationContext context = new FileSystemXmlApplicationContext("file:" + springContextPath); + + application.setAttribute("springContext", context); + session.setAttribute("springContextData", context.toString()); + response.sendRedirect("sql.jsp"); + } } diff --git a/src/com/waratek/spiracle/sql/util/ConnectionUtil.java b/src/com/waratek/spiracle/sql/util/ConnectionUtil.java index 588e78f..94081a2 100644 --- a/src/com/waratek/spiracle/sql/util/ConnectionUtil.java +++ b/src/com/waratek/spiracle/sql/util/ConnectionUtil.java @@ -30,21 +30,21 @@ public class ConnectionUtil { private static final Logger logger = Logger.getLogger(ParameterNullFix.class); - public static Connection getConnection(ServletContext application, String connectionType) throws SQLException { - Connection con = null; - logger.info("Connection Type: " + connectionType); - if(connectionType.equals("c3p0")) { - ComboPooledDataSource ds = (ComboPooledDataSource)application.getAttribute("connectionPool"); - con = ds.getConnection(); - } else if(connectionType.equals("java")) { - con = (Connection)application.getAttribute("connection"); - } else if(connectionType.equals("spring")) { - FileSystemXmlApplicationContext context = (FileSystemXmlApplicationContext)application.getAttribute("springContext"); - DriverManagerDataSource dmds = (DriverManagerDataSource)context.getBean("dataSource"); - con = dmds.getConnection(); - } - - logger.info("Returning connection: " + con.toString()); - return con; - } + public static Connection getConnection(ServletContext application, String connectionType) throws SQLException { + Connection con = null; + logger.info("Connection Type: " + connectionType); + if(connectionType.equals("c3p0")) { + ComboPooledDataSource ds = (ComboPooledDataSource)application.getAttribute("connectionPool"); + con = ds.getConnection(); + } else if(connectionType.equals("java")) { + con = (Connection)application.getAttribute("connection"); + } else if(connectionType.equals("spring")) { + FileSystemXmlApplicationContext context = (FileSystemXmlApplicationContext)application.getAttribute("springContext"); + DriverManagerDataSource dmds = (DriverManagerDataSource)context.getBean("dataSource"); + con = dmds.getConnection(); + } + + logger.info("Returning connection: " + con.toString()); + return con; + } } diff --git a/src/com/waratek/spiracle/sql/util/SelectUtil.java b/src/com/waratek/spiracle/sql/util/SelectUtil.java index 777e07a..c1f7c32 100644 --- a/src/com/waratek/spiracle/sql/util/SelectUtil.java +++ b/src/com/waratek/spiracle/sql/util/SelectUtil.java @@ -39,7 +39,7 @@ public static void executeQuery(String sql, ServletContext application, HttpServ String connectionType = null; Connection con = null; int fetchSize = (Integer) application.getAttribute("fetchSize"); - + TagUtil.printPageHead(out); TagUtil.printPageNavbar(out); TagUtil.printContentDiv(out); @@ -51,7 +51,7 @@ public static void executeQuery(String sql, ServletContext application, HttpServ } else { connectionType = request.getParameter("connectionType"); } - con = ConnectionUtil.getConnection(application, connectionType); + con = ConnectionUtil.getConnection(application, connectionType); out.println("
"); out.println("

SQL Query:

"); out.println("
");
@@ -71,7 +71,7 @@ public static void executeQuery(String sql, ServletContext application, HttpServ
 			con.close();
 		} catch(SQLException e) {
 			if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) {
-				response.setStatus(550);				
+				response.setStatus(550);
 			} else {
 				response.setStatus(500);
 			}
@@ -132,7 +132,7 @@ private static void writeToResponse(Boolean allResults, Boolean showOutput, Serv
 
 	private static void writeRow(ServletOutputStream out, ResultSet rs, ResultSetMetaData metaData) throws IOException, SQLException {
 		out.println("");
-		for(int i = 1; i <= metaData.getColumnCount(); i++) {           
+		for(int i = 1; i <= metaData.getColumnCount(); i++) {
 			Object content = rs.getObject(i);
 			if(content != null) {
 				out.println("" + content.toString() + "");
diff --git a/src/com/waratek/spiracle/sql/util/TagUtil.java b/src/com/waratek/spiracle/sql/util/TagUtil.java
index 3f560fb..da33196 100644
--- a/src/com/waratek/spiracle/sql/util/TagUtil.java
+++ b/src/com/waratek/spiracle/sql/util/TagUtil.java
@@ -21,19 +21,19 @@
 
 public class TagUtil {
 	static void printPageHead(ServletOutputStream out) throws IOException {
-        out.println("");
-        out.println("");
-        out.println("");
-        out.println("");
-        out.println("");
-        out.println("");
-        out.println("");
+		out.println("");
+		out.println("");
+		out.println("");
+		out.println("");
+		out.println("");
+		out.println("");
+		out.println("");
 
-        out.println("Spiracle - SQL");
-        out.println("");
-        out.println("");
+		out.println("Spiracle - SQL");
+		out.println("");
+		out.println("");
 	}
-	
+
 	static void printPageNavbar(ServletOutputStream out) throws IOException {
 		out.println("
"); out.println("
"); @@ -57,16 +57,16 @@ static void printPageNavbar(ServletOutputStream out) throws IOException { out.println("
"); out.println("
"); } - + static void printContentDiv(ServletOutputStream out) throws IOException { out.println("
"); } - + static void printPageFooter(ServletOutputStream out) throws IOException { out.println("
"); out.println("
"); - out.println(""); - out.println(""); - out.println(""); + out.println(""); + out.println(""); + out.println(""); } } From dec52eefae80fa9cec26da257b3820c4bed2558a Mon Sep 17 00:00:00 2001 From: skenny Date: Mon, 2 Feb 2015 14:54:23 +0000 Subject: [PATCH 10/12] Fix connection pool exhaustion on MySQL due to incorrect resource cleanup. --- .../waratek/spiracle/sql/util/SelectUtil.java | 56 ++++++++++++++----- .../waratek/spiracle/sql/util/UpdateUtil.java | 42 ++++++++++---- 2 files changed, 74 insertions(+), 24 deletions(-) diff --git a/src/com/waratek/spiracle/sql/util/SelectUtil.java b/src/com/waratek/spiracle/sql/util/SelectUtil.java index c1f7c32..9eb0f58 100644 --- a/src/com/waratek/spiracle/sql/util/SelectUtil.java +++ b/src/com/waratek/spiracle/sql/util/SelectUtil.java @@ -40,6 +40,9 @@ public static void executeQuery(String sql, ServletContext application, HttpServ Connection con = null; int fetchSize = (Integer) application.getAttribute("fetchSize"); + PreparedStatement stmt = null; + ResultSet rs = null; + TagUtil.printPageHead(out); TagUtil.printPageNavbar(out); TagUtil.printContentDiv(out); @@ -60,15 +63,13 @@ public static void executeQuery(String sql, ServletContext application, HttpServ logger.info(sql); - PreparedStatement stmt = con.prepareStatement(sql); + stmt = con.prepareStatement(sql); + logger.info("Created PreparedStatement: " + sql); stmt.setFetchSize(fetchSize); - ResultSet rs = stmt.executeQuery(); + rs = stmt.executeQuery(); + logger.info("Executed: " + sql); writeToResponse(allResults, showOutput, out, rs); - out.close(); - rs.close(); - stmt.close(); - con.close(); } catch(SQLException e) { if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) { response.setStatus(550); @@ -85,20 +86,49 @@ public static void executeQuery(String sql, ServletContext application, HttpServ while((e = e.getNextException()) != null) { out.println(e.getMessage() + "
"); } + } finally { try { - con.rollback(); - con.close(); - } catch (SQLException e1) { + if(rs != null) { + logger.info("Closing ResultSet " + rs); + rs.close(); + logger.info("Closed ResultSet " + rs); + } + } catch (SQLException rsCloseException) { if(logger.isDebugEnabled()) { - logger.debug(e1.getMessage(), e1); + logger.debug(rsCloseException.getMessage(), rsCloseException); } else { - logger.error(e1); + logger.error(rsCloseException); + } + } + try { + if(stmt != null) { + logger.info("Closing PreparedStatement " + stmt); + stmt.close(); + logger.info("Closed PreparedStatement " + stmt); + } + } catch (SQLException stmtCloseException) { + if(logger.isDebugEnabled()) { + logger.debug(stmtCloseException.getMessage(), stmtCloseException); + } else { + logger.error(stmtCloseException); + } + } + try { + if(con != null) { + logger.info("Closing Connection " + con); + con.close(); + logger.info("Closed Connection " + con); + } + } catch (SQLException conCloseException) { + if(logger.isDebugEnabled()) { + logger.debug(conCloseException.getMessage(), conCloseException); + } else { + logger.error(conCloseException); } } - TagUtil.printPageFooter(out); + out.close(); } - } private static void writeToResponse(Boolean allResults, Boolean showOutput, ServletOutputStream out, ResultSet rs) throws SQLException, IOException { diff --git a/src/com/waratek/spiracle/sql/util/UpdateUtil.java b/src/com/waratek/spiracle/sql/util/UpdateUtil.java index 1f6f1ae..2d82b88 100644 --- a/src/com/waratek/spiracle/sql/util/UpdateUtil.java +++ b/src/com/waratek/spiracle/sql/util/UpdateUtil.java @@ -35,6 +35,8 @@ public static void executeUpdate(String sql, ServletContext application, HttpSer ServletOutputStream out = response.getOutputStream(); String connectionType = null; Connection con = null; + + PreparedStatement stmt = null; TagUtil.printPageHead(out); TagUtil.printPageNavbar(out); @@ -56,15 +58,14 @@ public static void executeUpdate(String sql, ServletContext application, HttpSer logger.info(sql); - PreparedStatement stmt = con.prepareStatement(sql); + stmt = con.prepareStatement(sql); + logger.info("Created PreparedStatement: " + sql); int result = stmt.executeUpdate(); + logger.info("Executed: " + sql); + out.println("

Altered Rows:

"); out.print("
" + result + "
"); TagUtil.printPageFooter(out); - out.close(); - stmt.close(); - con.close(); - } catch(SQLException e) { if(e.getMessage().equals("Attempted to execute a query with one or more bad parameters.")) { response.setStatus(550); @@ -81,18 +82,37 @@ public static void executeUpdate(String sql, ServletContext application, HttpSer while((e = e.getNextException()) != null) { out.println(e.getMessage() + "
"); } + } finally { try { - con.rollback(); - con.close(); - } catch (SQLException e1) { + if(stmt != null) { + logger.info("Closing PreparedStatement " + stmt); + stmt.close(); + logger.info("Closed PreparedStatement " + stmt); + } + } catch (SQLException stmtCloseException) { if(logger.isDebugEnabled()) { - logger.debug(e1.getMessage(), e); + logger.debug(stmtCloseException.getMessage(), stmtCloseException); } else { - logger.error(e1); + logger.error(stmtCloseException); } } - out.println("
"); + try { + if(con != null) { + logger.info("Closing Connection " + con); + con.close(); + logger.info("Closed Connection " + con); + } + } catch (SQLException conCloseException) { + if(logger.isDebugEnabled()) { + logger.debug(conCloseException.getMessage(), conCloseException); + } else { + logger.error(conCloseException); + } + } + + out.println(""); TagUtil.printPageFooter(out); + out.close(); } } } From 9fa89273edff1612c34151ee226e3f0b560efbbf Mon Sep 17 00:00:00 2001 From: skenny Date: Tue, 3 Feb 2015 11:53:20 +0000 Subject: [PATCH 11/12] Cleanup config file, add optional file logging configuration. --- WebContent/conf/Spiracle.properties | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/WebContent/conf/Spiracle.properties b/WebContent/conf/Spiracle.properties index 83a6e16..8300d3b 100644 --- a/WebContent/conf/Spiracle.properties +++ b/WebContent/conf/Spiracle.properties @@ -1,7 +1,7 @@ -c3p0.classname=com.mysql.jdbc.Driver -c3p0.url=jdbc:mysql://phy05:3306/test +c3p0.classname=oracle.jdbc.driver.OracleDriver +c3p0.url=jdbc:oracle:thin:@localhost:1521:XE c3p0.username=test -c3p0.password=5{Ck&zJi +c3p0.password=test c3p0.maxPoolSize=50 java.classname=oracle.jdbc.driver.OracleDriver @@ -15,10 +15,17 @@ spring.path=/path/to/spring-context.xml application.loggingEnabled=True -# Log4j Configuration ## + Log4j Configuration ## log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%p] [%d{ISO8601}] [%F:%L] [%m]%n \ No newline at end of file +log4j.appender.stdout.layout.ConversionPattern=[%p] [%d{ISO8601}] [%F:%L] [%m]%n + +#log4j.rootLogger=DEBUG, FILE +# +#log4j.appender.FILE=org.apache.log4j.FileAppender +#log4j.appender.FILE.File=/tmp/spiracle.log +#log4j.appender.FILE.layout=org.apache.log4j.PatternLayout +#log4j.appender.FILE.layout.ConversionPattern=[%p] [%d{ISO8601}] [%F:%L] [%m]%n \ No newline at end of file From c729b6c1eb3c2756a08f2f27b7ee396e325ed0b5 Mon Sep 17 00:00:00 2001 From: skenny Date: Tue, 3 Feb 2015 12:00:05 +0000 Subject: [PATCH 12/12] Fix typo in config file. --- WebContent/conf/Spiracle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebContent/conf/Spiracle.properties b/WebContent/conf/Spiracle.properties index 8300d3b..b4e00bf 100644 --- a/WebContent/conf/Spiracle.properties +++ b/WebContent/conf/Spiracle.properties @@ -15,7 +15,7 @@ spring.path=/path/to/spring-context.xml application.loggingEnabled=True - Log4j Configuration ## +#Log4j Configuration ## log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender