geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r701393 - in /geronimo/server/trunk/plugins/system-database: sysdb-console-jetty/src/main/plan/ sysdb-console-tomcat/src/main/plan/ sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/ sysdb-portlets/src/main/resources/ sysd...
Date Fri, 03 Oct 2008 14:46:58 GMT
Author: dwoods
Date: Fri Oct  3 07:46:58 2008
New Revision: 701393

URL: http://svn.apache.org/viewvc?rev=701393&view=rev
Log:
GERONIMO-4225 refactor patch to keep DB Manager -> Run SQL db centric while adding an init-param
so we can also have a datasource centric DB Pools -> Run SQL instance from the same code

Modified:
    geronimo/server/trunk/plugins/system-database/sysdb-console-jetty/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/system-database/sysdb-console-tomcat/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase_zh.properties
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/portlet.xml
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLHelp.jsp
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/web.xml

Modified: geronimo/server/trunk/plugins/system-database/sysdb-console-jetty/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-console-jetty/src/main/plan/plan.xml?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-console-jetty/src/main/plan/plan.xml
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-console-jetty/src/main/plan/plan.xml
Fri Oct  3 07:46:58 2008
@@ -40,7 +40,7 @@
     <gbean name="DBWizard" class="org.apache.geronimo.pluto.AdminConsoleExtensionGBean">
         <attribute name="pageTitle">Services/Database Pools</attribute>
         <attribute name="portletContext">/system-database</attribute>
-        <attribute name="portletList">[DBWizard]</attribute>
+        <attribute name="portletList">[DBWizard,RunSQLDS]</attribute>
         <attribute name="icon">/images/ico_db_16x16.gif</attribute>
         <reference name="PortalContainerServices">
             <name>PlutoPortalServices</name>

Modified: geronimo/server/trunk/plugins/system-database/sysdb-console-tomcat/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-console-tomcat/src/main/plan/plan.xml?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-console-tomcat/src/main/plan/plan.xml
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-console-tomcat/src/main/plan/plan.xml
Fri Oct  3 07:46:58 2008
@@ -41,7 +41,7 @@
     <gbean name="DBWizard" class="org.apache.geronimo.pluto.AdminConsoleExtensionGBean">
         <attribute name="pageTitle">Services/Database Pools</attribute>
         <attribute name="portletContext">/system-database</attribute>
-        <attribute name="portletList">[DBWizard]</attribute>
+        <attribute name="portletList">[DBWizard,RunSQLDS]</attribute>
         <attribute name="icon">/images/ico_db_16x16.gif</attribute>
         <reference name="PortalContainerServices">
             <name>PlutoPortalServices</name>

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
Fri Oct  3 07:46:58 2008
@@ -72,8 +72,8 @@
      * @param derbySysHome
      * @return
      */
-    public Collection getDerbyDatabases(String derbySysHome) {
-        Vector databases = new Vector();
+    public Collection<String> getDerbyDatabases(String derbySysHome) {
+        List<String> databases = new ArrayList<String>();
         File f = new File(derbySysHome);
         // Check if this is a directory
         if (f.isDirectory()) {

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
Fri Oct  3 07:46:58 2008
@@ -132,7 +132,7 @@
         return result;
     }
 
-    public String runSQL(String dsName, String sql) {
+    public String runSQL(String connName, String sql, Boolean dsConn) {
         String result = SQL_SUCCESS_MSG;
 
         if ((sql == null) || (sql.trim().length() == 0)) {
@@ -144,8 +144,11 @@
         Connection conn = null;
         Statement s = null;
         try {
-
-            conn = DerbyConnectionUtil.getDataSourceConnection(dsName);
+            if (dsConn) {
+                conn = DerbyConnectionUtil.getDataSourceConnection(connName);
+            } else {
+                conn = DerbyConnectionUtil.getDerbyConnection(connName);
+            }
             conn.setAutoCommit(false);
 
             s = conn.createStatement();
@@ -218,6 +221,6 @@
                 "create table derbyTbl1(num int, addr varchar(40));"
                         + "create table derbyTbl2(num int, addr varchar(40));"
                         + "create table derbyTbl3(num int, addr varchar(40));"
-                        + "insert into derb");
+                        + "insert into derb", false);
     }
 }

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
Fri Oct  3 07:46:58 2008
@@ -48,6 +48,10 @@
     private static final String BACKUPDB_ACTION = "Backup";
 
     private static final String RESTOREDB_ACTION = "Restore";
+    
+    private static final String DATASOURCE_MODE = "datasource";
+
+    private static final String DATABASE_MODE = "database";
 
     private static RunSQLHelper sqlHelper = new RunSQLHelper();
 
@@ -59,7 +63,7 @@
 
     private PortletRequestDispatcher helpView;
 
-    private Collection databases;
+    private Collection<String> databases;
     
     private Collection<String> dataSourceNames;
 
@@ -78,6 +82,8 @@
     private String sqlStmts;
 
     private String actionResult;
+    
+    private String connectionMode;  // either datasource or database
 
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
@@ -95,7 +101,7 @@
         } else if (DELETEDB_ACTION.equals(action)) {
             actionResult = sqlHelper.deleteDB(DerbyConnectionUtil.getDerbyHome(), deleteDB);
         } else if (RUNSQL_ACTION.equals(action)) {
-            actionResult = sqlHelper.runSQL(useDB, sqlStmts);
+            actionResult = sqlHelper.runSQL(useDB, sqlStmts, RunSQLPortlet.DATASOURCE_MODE.equals(connectionMode));
         } else if (BACKUPDB_ACTION.equals(action)) {
             actionResult = sqlHelper.backupDB(DerbyConnectionUtil.getDerbyHome(), backupDB);
         } else if (RESTOREDB_ACTION.equals(action)) {
@@ -115,7 +121,8 @@
         renderRequest.setAttribute("databases", databases);
         renderRequest.setAttribute("dataSourceNames", dataSourceNames);
         renderRequest.setAttribute("sqlStmts", sqlStmts);
-        renderRequest.setAttribute("useDB", useDB);	
+        renderRequest.setAttribute("useDB", useDB);
+        renderRequest.setAttribute("connectionMode", connectionMode);
         if (RUNSQL_ACTION.equals(action)) {
             // check if it's a single Select statement
             if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';') == -1)
@@ -148,6 +155,7 @@
 
     protected void doHelp(RenderRequest renderRequest,
             RenderResponse renderResponse) throws PortletException, IOException {
+        renderRequest.setAttribute("connectionMode", connectionMode);
         helpView.include(renderRequest, renderResponse);
     }
 
@@ -161,12 +169,26 @@
                 HELPVIEW_JSP);
         databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
         dataSourceNames = dbHelper.getDataSourceNames();
+        String mode = portletConfig.getInitParameter("connectionMode");
+        if ((mode != null) && (mode.trim().equalsIgnoreCase(RunSQLPortlet.DATASOURCE_MODE)))
{
+            connectionMode = RunSQLPortlet.DATASOURCE_MODE;
+        } else {
+            connectionMode = RunSQLPortlet.DATABASE_MODE;
+        }
     }
 
     public void destroy() {
         normalView = null;
         maximizedView = null;
         helpView = null;
+        if (databases != null) {
+            databases.clear();
+            databases = null;
+        }
+        if (dataSourceNames != null) {
+            dataSourceNames.clear();
+            dataSourceNames = null;
+        }
         super.destroy();
     }
 

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
Fri Oct  3 07:46:58 2008
@@ -199,7 +199,8 @@
 internaldb.common.tableTypes                  = Table Types
 internaldb.common.tables                      = Tables
 internaldb.common.timeDateFunctions           = Time Date Functions
-internaldb.common.useDB                       = Use DataSource
+internaldb.common.useDB                       = Use DB
+internaldb.common.useDS                       = Use DataSource
 internaldb.common.userName                    = Username
 internaldb.common.viewContents                = View Contents
 internaldb.common.viewDatabases               = View Databases
@@ -215,7 +216,8 @@
 internaldb.runSQLHelp.deleteDBExp             = Delete an existing database, by selecting
it from the pull-down menu and then clicking on &quot;Delete.&quot;
 internaldb.runSQLHelp.runSQLExp               = Enter the SQL commands, separated by semicolons,
in the "SQL Command/s" text box. To run the SQL command(s), click on the "Run SQL" button.
 internaldb.runSQLHelp.summary                 = Allows the user to run SQL commands to manipulate
the data in the tables, create a new database or delete a database. The user can enter the
SQL commands in the &quot;SQL Command(s)&quot; text box and click on &quot;Run
SQL.&quot;
-internaldb.runSQLHelp.useDBExp                = Select a database to update from the pull-down
menu.
+internaldb.runSQLHelp.useDBExp                = Select a database to use from the pull-down
menu.
+internaldb.runSQLHelp.useDSExp                = Select a datasource to use from the pull-down
menu.
 internaldb.runSQLNormal.note1                 = 1) Use ';' to separate multiple statements
 internaldb.runSQLNormal.note2                 = 2) Query results will be displayed for single
'Select' statement
 internaldb.runSQLNormal.note3                 = 3) Use single quotes to encapsulate literal
strings

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase_zh.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase_zh.properties?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase_zh.properties
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase_zh.properties
Fri Oct  3 07:46:58 2008
@@ -198,6 +198,7 @@
 internaldb.common.tables                      = \u8868
 internaldb.common.timeDateFunctions           = \u65F6\u95F4/\u65E5\u671F\u51FD\u6570
 internaldb.common.useDB                       = \u4F7F\u7528\u6570\u636E\u5E93
+internaldb.common.useDS                       = Use DataSource
 internaldb.common.userName                    = \u7528\u6237\u540D
 internaldb.common.viewContents                = \u67E5\u770B\u5185\u5BB9
 internaldb.common.viewDatabases               = \u67E5\u770B\u6570\u636E\u5E93
@@ -214,6 +215,7 @@
 internaldb.runSQLHelp.runSQLExp               = \u5728"SQL\u547D\u4EE4"\u6587\u672C\u6846\u4E2D\uFF0C\u8F93\u5165\u7528\u5206\u53F7\u5206\u5272\u7684SQL\u547D\u4EE4\uFF0C\u70B9\u51FB"\u8FD0\u884C
SQL"\u6309\u94AE\u6765\u8FD0\u884CSQL\u547D\u4EE4\u3002
 internaldb.runSQLHelp.summary                 = \u5141\u8BB8\u7528\u6237\u8FD0\u884C\uFF33\uFF31\uFF2C\u547D\u4EE4\u53BB\u64CD\u4F5C\u8868\u4E2D\u7684\u6570\u636E\uFF0C\u521B\u5EFA\u6216\u5220\u9664\u6570\u636E\u5E93\u3002\u5728&quot;SQL\u547D\u4EE4&quot;\u6587\u672C\u6846\u4E2D\uFF0C\u7528\u6237\u53EF\u4EE5\u8F93\u5165SQL\u547D\u4EE4,\u5E76\u70B9\u51FB&quot;\u8FD0\u884CSQL.&quot;
 internaldb.runSQLHelp.useDBExp                = \u4ECE\u4E0B\u62C9\u6846\u4E2D\u9009\u62E9\u8981\u66F4\u65B0\u7684\u6570\u636E\u5E93\u3002
+internaldb.runSQLHelp.useDSExp                = Select a datasource to use from the pull-down
menu.
 internaldb.runSQLNormal.note1                 = 1) \u4F7F\u7528';'\u5206\u5F00\u591A\u4E2A\u8BED\u53E5
 internaldb.runSQLNormal.note2                 = 2) \u5355\u4E2A'Select'\u8BED\u53E5\u7684\u67E5\u8BE2\u7ED3\u679C\u4F1A\u88AB\u663E\u793A
 internaldb.runSQLNormal.note3                 = 3) \u4F7F\u7528\u5355\u5F15\u53F7\u62EC\u4F4F\u6587\u672C\u5B57\u7B26\u4E32

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/portlet.xml?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/portlet.xml
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/portlet.xml
Fri Oct  3 07:46:58 2008
@@ -96,6 +96,33 @@
             <short-title>Run SQL</short-title>
             <keywords>Run SQL</keywords>
         </portlet-info>
+        <init-param>
+            <name>connectionMode</name>
+            <value>database</value>
+        </init-param>
+    </portlet>
+
+    <portlet>
+        <description>Portlet for running DataSource SQL commands</description>
+        <portlet-name>RunSQLDS</portlet-name>
+        <display-name>DataSource Run SQL Portlet</display-name>
+        <portlet-class>org.apache.geronimo.console.internaldb.RunSQLPortlet</portlet-class>
+        <expiration-cache>-1</expiration-cache>
+        <supports>
+            <mime-type>text/html</mime-type>
+            <portlet-mode>VIEW</portlet-mode>
+            <portlet-mode>HELP</portlet-mode>
+        </supports>
+        <supported-locale>en</supported-locale>
+        <portlet-info>
+            <title>Run SQL</title>
+            <short-title>Run SQL</short-title>
+            <keywords>Run SQL</keywords>
+        </portlet-info>
+        <init-param>
+            <name>connectionMode</name>
+            <value>datasource</value>
+        </init-param>
     </portlet>
 
     <portlet>

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLHelp.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLHelp.jsp?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLHelp.jsp
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLHelp.jsp
Fri Oct  3 07:46:58 2008
@@ -14,11 +14,25 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 --%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
 <fmt:setBundle basename="systemdatabase"/>
 <p><fmt:message key="internaldb.runSQLHelp.summary"/><br>
   </p>
 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
+<c:choose>
+ <c:when test="${connectionMode == 'datasource'}">
+  <tr>
+    <td class="MediumBackground" style="padding: 10px 10px 10px 5px; color: #1E1E52;"
width="150" align="right" valign="top"><fmt:message key="internaldb.common.useDS"/>:</td>
+    <td class="LightBackground" style="padding: 10px 5px 10px 10px" valign="top"><fmt:message
key="internaldb.runSQLHelp.useDSExp"/></td>
+  </tr>
+  <tr>
+    <td class="MediumBackground" style="padding: 10px 10px 10px 5px; color: #1E1E52;"
width="150" align="right" valign="top">
+      <img src="/console/images/run_sql.gif" alt="Run SQL"/></td>
+    <td class="LightBackground" style="padding: 10px 5px 10px 10px" valign="top"><fmt:message
key="internaldb.runSQLHelp.runSQLExp"/></td>
+  </tr>
+ </c:when>
+ <c:otherwise>
   <tr>
     <td class="MediumBackground" style="padding: 10px 10px 10px 5px; color: #1E1E52;"
width="150" align="right" valign="top"><fmt:message key="internaldb.common.createDB"/>:
/ <br>      
       <img src="/console/images/create.gif" alt="Create"/></td>
@@ -38,4 +52,6 @@
       <img src="/console/images/run_sql.gif" alt="Run SQL"/></td>
     <td class="LightBackground" style="padding: 10px 5px 10px 10px" valign="top"><fmt:message
key="internaldb.runSQLHelp.runSQLExp"/></td>
   </tr>
+ </c:otherwise>
+</c:choose>
 </table>

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
Fri Oct  3 07:46:58 2008
@@ -47,6 +47,8 @@
 <form name="<portlet:namespace/>DBForm" action="<portlet:actionURL portletMode='view'/>"
method="post">
 <input type="hidden" name="action" value="" />
 <table width="100%"  border="0">
+<c:choose>
+ <c:when test="${connectionMode == 'database'}">
   <tr>
     <td><div align="right"><label for="<portlet:namespace/>createDB"><fmt:message
key="internaldb.common.createDB"/></label>:</div></td>
     <td><input name="createDB" id="<portlet:namespace/>createDB" type="text"
size="30">&nbsp;
@@ -67,12 +69,26 @@
     <td><div align="right"><label for="<portlet:namespace/>useDB"><fmt:message
key="internaldb.common.useDB"/></label>:</div></td>
     <td>
       <select name="useDB" id="<portlet:namespace/>useDB">
+      <c:forEach var="db" items="${databases}" varStatus="status">
+        <option value="${db}"<c:if test="${useDB==db}"> selected="selected"</c:if>>${db}</option>
+      </c:forEach>
+      </select>&nbsp;
+      <input type="submit" value="Run SQL" onClick="return <portlet:namespace/>validateForm3();"></td>
+  </tr>
+ </c:when>
+ <c:otherwise>
+  <tr>
+    <td><div align="right"><label for="<portlet:namespace/>useDB"><fmt:message
key="internaldb.common.useDS"/></label>:</div></td>
+    <td>
+      <select name="useDB" id="<portlet:namespace/>useDB">
       <c:forEach var="dsName" items="${dataSourceNames}" varStatus="status">
         <option value="${dsName}"<c:if test="${useDB==dsName}"> selected="selected"</c:if>>${dsName}</option>
       </c:forEach>
       </select>&nbsp;
       <input type="submit" value="Run SQL" onClick="return <portlet:namespace/>validateForm3();"></td>
   </tr>
+ </c:otherwise>
+</c:choose>
   <tr>
     <td></td>
     <td><div align="left"><label for="<portlet:namespace/>sqlStmts"><fmt:message
key="internaldb.common.SQLCommands"/></label>:</div></td>
@@ -113,52 +129,65 @@
 
 <%-- Display query result from single select statement --%>
 <c:if test="${!empty singleSelectStmt}">
-
-<%-- Select statement --%>
-<sql:transaction dataSource="${ds}">
-  <sql:query var="table">
-    <%= request.getAttribute("singleSelectStmt") %>
-  </sql:query>
-</sql:transaction>
-
-<center><b><fmt:message key="internaldb.common.queryResult"/></b></center>
-<table width="100%">
-  <tr>
-  <%-- Get the column names for the header of the table --%>
-  <c:forEach var="columnName" items="${table.columnNames}">
-    <td class="DarkBackground"><c:out value="${columnName}" /></td>
-  </c:forEach>
-  </tr>
-  
-  <%-- Check if there are table data to display --%>
-  <c:choose>
-    <c:when test="${table.rowCount == 0}">
-      <tr>
-        <td class="LightBackground" colspan="<c:out value='${fn:length(table.columnNames)}'
/>" align="center">*** <fmt:message key="internaldb.common.empty"/> ***</td>
-      </tr>
-    </c:when>
-    <c:otherwise>
-      <%-- Get the value of each column while iterating over rows --%>
-      <c:forEach var="row" items="${table.rowsByIndex}" varStatus="status">
-        <jsp:useBean type="javax.servlet.jsp.jstl.core.LoopTagStatus" id="status" />
-        <tr>
-        <c:choose>
-          <c:when test="<%= status.getCount() % 2 == 1 %>">
-            <c:forEach var="column" items="${row}">
-              <td class="LightBackground"><c:out value="${column}" /></td>
-            </c:forEach>
-          </c:when>
-            <c:otherwise>
-            <c:forEach var="column" items="${row}">
-              <td class="MediumBackground"><c:out value="${column}" /></td>
-            </c:forEach>
-            </c:otherwise>
-          </c:choose>
-        </tr>
-      </c:forEach>
-    </c:otherwise>
-  </c:choose>
-</table>
+    <%-- If in Database mode, make sure we have a Derby connection --%>
+    <c:if test="${connectionMode == 'database'}">
+      <c:if test="${ds == null}">
+        <%-- Create the connection manually --%>
+        <sql:setDataSource
+          var="ds"
+          driver="org.apache.derby.jdbc.EmbeddedDriver"
+          url="jdbc:derby:${useDB};create=true"
+          user=""
+          password=""
+        />
+      </c:if>
+	</c:if>
+
+	<%-- Select statement --%>
+	<sql:transaction dataSource="${ds}">
+	  <sql:query var="table">
+	    <%= request.getAttribute("singleSelectStmt") %>
+	  </sql:query>
+	</sql:transaction>
+	
+	<center><b><fmt:message key="internaldb.common.queryResult"/></b></center>
+	<table width="100%">
+	  <tr>
+	  <%-- Get the column names for the header of the table --%>
+	  <c:forEach var="columnName" items="${table.columnNames}">
+	    <td class="DarkBackground"><c:out value="${columnName}" /></td>
+	  </c:forEach>
+	  </tr>
+	  
+	  <%-- Check if there are table data to display --%>
+	  <c:choose>
+	    <c:when test="${table.rowCount == 0}">
+	      <tr>
+	        <td class="LightBackground" colspan="<c:out value='${fn:length(table.columnNames)}'
/>" align="center">*** <fmt:message key="internaldb.common.empty"/> ***</td>
+	      </tr>
+	    </c:when>
+	    <c:otherwise>
+	      <%-- Get the value of each column while iterating over rows --%>
+	      <c:forEach var="row" items="${table.rowsByIndex}" varStatus="status">
+	        <jsp:useBean type="javax.servlet.jsp.jstl.core.LoopTagStatus" id="status" />
+	        <tr>
+	        <c:choose>
+	          <c:when test="<%= status.getCount() % 2 == 1 %>">
+	            <c:forEach var="column" items="${row}">
+	              <td class="LightBackground"><c:out value="${column}" /></td>
+	            </c:forEach>
+	          </c:when>
+	            <c:otherwise>
+	            <c:forEach var="column" items="${row}">
+	              <td class="MediumBackground"><c:out value="${column}" /></td>
+	            </c:forEach>
+	            </c:otherwise>
+	          </c:choose>
+	        </tr>
+	      </c:forEach>
+	    </c:otherwise>
+	  </c:choose>
+	</table>
 </c:if>
 
 </form>

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/web.xml?rev=701393&r1=701392&r2=701393&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/web.xml
Fri Oct  3 07:46:58 2008
@@ -66,6 +66,16 @@
         </init-param>
     </servlet>
 
+    <servlet>
+        <display-name>Pluto Wrapper for DataSource Run SQL Portlet</display-name>
+        <servlet-name>RunSQLDS</servlet-name>
+        <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
+        <init-param>
+            <param-name>portlet-name</param-name>
+            <param-value>RunSQLDS</param-value>
+        </init-param>
+    </servlet>
+
    <servlet>
         <display-name>Pluto Wrapper for Derby Log Viewer Portlet</display-name>
         <servlet-name>DerbyLogViewer</servlet-name>
@@ -107,6 +117,11 @@
     </servlet-mapping>
 
     <servlet-mapping>
+        <servlet-name>RunSQLDS</servlet-name>
+        <url-pattern>/PlutoInvoker/RunSQLDS/*</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
         <servlet-name>DerbyLogViewer</servlet-name>
         <url-pattern>/PlutoInvoker/DerbyLogViewer/*</url-pattern>
     </servlet-mapping>



Mime
View raw message