D
Doug Schaible
I am trying to create a JSP that has a class in it. (kind of like a
function) I am having a lot of trouble getting it to work though. I
get this error: /tmp/jsp_servlet/_wlm/__call_sp_start_stop.java:117:
inner classes cannot have static declarations
public static void Command( String databaseURL,
java.sql.Connection db2, String command, String results) { //[
/wlm/call_sp_start_stop.jsp; Line: 31]
My code is below. Can someone please guide me in the right direction.
Thanks,
Doug
<%@ page import="java.sql.*" errorPage="error.jsp";%>
<%@ page import="java.util.*" %>
<%
String ErrorMessage ="NONE";
boolean Continue;
Continue = true;
String databaseURL = "";
String user = "";
String password = "";
String sqlid = "";
String schema = "";
String sp = "";
String action = "";
String command = "";
String results = "";
java.sql.Connection db2 = null;
java.sql.ResultSet rs;
PreparedStatement stmt1;
java.sql.Statement st;
int one = 1;
int sqlCode = 0;
int r = 0;
class Wlm{
public static void Command( String databaseURL, java.sql.Connection
db2, String command, String results) {
java.sql.Statement st2;
java.sql.ResultSet rs2;
int one2 = 1;
db2.close();
java.util.Properties properties = new java.util.Properties ();
properties.setProperty ("user", "xxxxx");
properties.setProperty ("password", "xxxxxx");
db2 = java.sql.DriverManager.getConnection (databaseURL,
properties);
((com.ibm.db2.jcc.DB2Connection)db2).setDB2ClientApplicationInformation("WLM_QUERY_WEB");
// set the path to our schema name so we can find our procedure
st2 = db2.createStatement();
st2.execute("SET CURRENT FUNCTION PATH DB2SYS");
CallableStatement stmtSP = db2.prepareCall("CALL
DB2SYS.DB2_COMMAND(?)");
stmtSP.setString(1, command.toUpperCase());
stmtSP.execute();
results = "";
rs2 = stmtSP.getResultSet();
while (rs2.next())
{
results = results + "<br>" + rs2.getString(one2);
}
}
}
//
try
{
databaseURL = request.getParameter("ssid");
user = request.getParameter("userid");
password = request.getParameter("password");
sqlid = request.getParameter("sqlid");
schema = request.getParameter("schema");
sp = request.getParameter("sp");
action = request.getParameter("action");
}
catch(Exception e)
{
//
}
//-- Load the JDBC driver class
Class.forName("com.ibm.db2.jcc.DB2Driver");
.... lots of code here that is working
//create command
if(action.equals("Start"))
{
command = "-start procedure(" + schema.trim() + "." + sp + ")";
}
else if(action.equals("Stop - Reject"))
{
command = "-stop procedure(" + schema.trim() + "." + sp + ")
action(reject)";
}
else if(action.equals("Stop - Queue"))
{
command = "-stop procedure(" + schema.trim() + "." + sp + ")
action(queue)";
}
else
{
Continue = false;
ErrorMessage = "Command action not know. Command aborted.";
}
}
//call sp
if( Continue )
{
Wlm.Command(databaseURL, db2, command, results);
}
// Close our DB2 Connection
if( Continue )
{
db2.close();
}
%>
<html>
<%
if (!Continue)
{
out.println("<h1>ERROR: </h1>" + ErrorMessage);
}
%>
<%
if (Continue)
{
out.println("<h1>Success: </h1><p>" + results);
out.println("<h3>Warning: </h3>" + ErrorMessage);
}
%>
</body>
</html>
function) I am having a lot of trouble getting it to work though. I
get this error: /tmp/jsp_servlet/_wlm/__call_sp_start_stop.java:117:
inner classes cannot have static declarations
public static void Command( String databaseURL,
java.sql.Connection db2, String command, String results) { //[
/wlm/call_sp_start_stop.jsp; Line: 31]
My code is below. Can someone please guide me in the right direction.
Thanks,
Doug
<%@ page import="java.sql.*" errorPage="error.jsp";%>
<%@ page import="java.util.*" %>
<%
String ErrorMessage ="NONE";
boolean Continue;
Continue = true;
String databaseURL = "";
String user = "";
String password = "";
String sqlid = "";
String schema = "";
String sp = "";
String action = "";
String command = "";
String results = "";
java.sql.Connection db2 = null;
java.sql.ResultSet rs;
PreparedStatement stmt1;
java.sql.Statement st;
int one = 1;
int sqlCode = 0;
int r = 0;
class Wlm{
public static void Command( String databaseURL, java.sql.Connection
db2, String command, String results) {
java.sql.Statement st2;
java.sql.ResultSet rs2;
int one2 = 1;
db2.close();
java.util.Properties properties = new java.util.Properties ();
properties.setProperty ("user", "xxxxx");
properties.setProperty ("password", "xxxxxx");
db2 = java.sql.DriverManager.getConnection (databaseURL,
properties);
((com.ibm.db2.jcc.DB2Connection)db2).setDB2ClientApplicationInformation("WLM_QUERY_WEB");
// set the path to our schema name so we can find our procedure
st2 = db2.createStatement();
st2.execute("SET CURRENT FUNCTION PATH DB2SYS");
CallableStatement stmtSP = db2.prepareCall("CALL
DB2SYS.DB2_COMMAND(?)");
stmtSP.setString(1, command.toUpperCase());
stmtSP.execute();
results = "";
rs2 = stmtSP.getResultSet();
while (rs2.next())
{
results = results + "<br>" + rs2.getString(one2);
}
}
}
//
try
{
databaseURL = request.getParameter("ssid");
user = request.getParameter("userid");
password = request.getParameter("password");
sqlid = request.getParameter("sqlid");
schema = request.getParameter("schema");
sp = request.getParameter("sp");
action = request.getParameter("action");
}
catch(Exception e)
{
//
}
//-- Load the JDBC driver class
Class.forName("com.ibm.db2.jcc.DB2Driver");
.... lots of code here that is working
//create command
if(action.equals("Start"))
{
command = "-start procedure(" + schema.trim() + "." + sp + ")";
}
else if(action.equals("Stop - Reject"))
{
command = "-stop procedure(" + schema.trim() + "." + sp + ")
action(reject)";
}
else if(action.equals("Stop - Queue"))
{
command = "-stop procedure(" + schema.trim() + "." + sp + ")
action(queue)";
}
else
{
Continue = false;
ErrorMessage = "Command action not know. Command aborted.";
}
}
//call sp
if( Continue )
{
Wlm.Command(databaseURL, db2, command, results);
}
// Close our DB2 Connection
if( Continue )
{
db2.close();
}
%>
<html>
<%
if (!Continue)
{
out.println("<h1>ERROR: </h1>" + ErrorMessage);
}
%>
<%
if (Continue)
{
out.println("<h1>Success: </h1><p>" + results);
out.println("<h3>Warning: </h3>" + ErrorMessage);
}
%>
</body>
</html>