db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Scott" <deni...@gmail.com>
Subject Re: Show Stopper
Date Fri, 15 Sep 2006 03:51:26 GMT
Wild late-night guess here, but is there any chance that you're
connecting from user ID "ID1" in Java Main, and a different user ID
"ID2" in the Applet, thereby implicitly selecting * from ID1.Profiles
in the first case, and ID2.Profiles in the second case (and getting
different results)?

If so, and you always want to qualify table names with a specific
schema instead of implicitly with the name of the user you connected
as, you may need to explicitly set the default schema with the SET
SCHEMA statement
(http://db.apache.org/derby/docs/10.1/ref/rrefsqlj32268.html).

Dan

On 14/09/06, Marl Atkins <marl@softlinksys.com> wrote:
> Hi:
>
> I'm admittedly worried about this one.
>
> I'm running a simple SQL Statement: Select * From Profiles ORDER BY FName,
> LName
>
> If I run it from within a Java Main proc I get 2 records which is correct.
> If I run it from a Browser/Applet through Javascript, I get NO errors but I
> get 0 records.
> I'm calling exactly the same proc in both cases.
> I got the browser to print the sql statement and it's correct.
>
> The amount of code total is a pretty good bit because of all the work I have
> to do to move data in and out of Java to Javascript. The Jar is almost 3
> megs. I can attach it if you like.
>
> This prints in the browser (I display Globals.sDebug in DHtml):
> ALERT In Do SearchGetting Row From String:
> Got Row From String
> Started Search
> Select * From Profiles ORDER BY LName, FName
> Executed Query
> Got0
>
> Got: 0
>
> From the main proc I do System.out.println(Globals.sDebug) and get:
> In Do SearchGetting Row From String: <br>Got Row From String<br>Started
> Search<br>Select * From Profiles ORDER BY LName, FName<BR>Executed
> Query<BR>Got2<BR><BR>Got: 2<BR>
>
> Any ideas as to why it works from a Java App and not from an Applet?
>
> Here's the proc that does the call:
> public DataTable getFilteredRecords(DataRow oFilter) throws Exception
>     {
>         ResultSet rs;
>         DataTable dtRecs;
>         StringBuffer sbSql = new StringBuffer();
>         try
>          {
>              sbSql.append("Select * From Profiles");
>              sbSql.append(buildFilter(oFilter));
>              sbSql.append(" ORDER BY LName, FName");
>              Globals.sDebug = sbSql.toString() + "<BR>"; //<<-- This shows
> up in the browser
>              oCn = Globals.getCliCn();
>              CliStmt oStmt = new CliStmt();
>              rs = oStmt.executeQuery(oCn, sbSql.toString());
>              Globals.sDebug = "Executed Query<BR>";     //<<-- This shows
up
> in the browser
>              dtRecs = new DataTable(rs);
>              Globals.sDebug = "Got" + dtRecs.Rows.length + "<BR>"; //<<--
> This shows up in the browser as 0
>              oStmt.close();
>              return dtRecs;
>          }
>          catch(Exception exp)
>          {
>              throw new Exception("Error in daProfile.getAllRecords:" +
> exp.getMessage());
>          }
>     }
>
> Here's the actual statement execution:
> public ResultSet executeQuery(Connection oCn, String sql) throws Exception
>     {
>         stmt = null;
>         final String strSql = sql;
>         sErr = "";
>         try
>         {
>             final Statement stmt =
> oCn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
> ResultSet.CONCUR_READ_ONLY);
>             ResultSet rs = (ResultSet)AccessController.doPrivileged(new
> PrivilegedAction() {
>                 public Object run()
>                 {
>                     try
>                     {
>                         return stmt.executeQuery(strSql);
>                     }
>                     catch(Exception exp)
>                     {
>                         sErr = exp.getMessage();
>                         return null;
>                     }
>                 }
>             });
>             if(sErr != "")
>             {
>                 throw (new Exception("Error in CliStmt.executeQuery:<br>" +
>                     sql + "<br>" + sErr));
>             }
>             return rs;
>         }
>         catch (Exception exp)
>         {
>             throw (new Exception("Error in CliStmt.executeQuery:\r\n" +
>                     sql + "\r\n" + exp.getMessage()));
>         }
>     }
>
>
>
>
> Marl K. Atkins
> Microsoft Certified Professional
> SoftLink Systems, Inc.
> (407) 388-1886
>
>

Mime
View raw message