Boolean in databases

Can ayone tell me what's the easiest way to store 'boolean' values into a
database?
Most of the database types described in the data conversion tables of
chapter 4 of "Accessing Databases" can only be selected into or inserted
from a boolean value, but not both!
TIA.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

Can ayone tell me what's the easiest way to store 'boolean' values into a
database?convert the boolean value to an integer value an write it as
a smallint (e.g.
for ODBC) into the database.
smallint is only 16 bit but you don't get a problem with the
integerdata type
because it's range is between 0 and 1
e.g.
convertBooleanToInteger(BooleanValue:boolean) : integer
If BooleanValue then
return(1);
else
return(0);
end if;
and
convertIntegerToBoolean(IntegerValue:integer) : boolean
If IntegerValue = 1 then
return(TRUE);
else
return(FALSE);
end if;There should be no need to convert it between an integer and a boolean.
We read/write the boolean directly from/to the database. The database
side is SMALLINT DEFAULT 0 NOT NULL and the forte attribute is boolean.
Forte handles the conversion.
Cheers
David
Lumley Technology
++61 9248 1356
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

Similar Messages

  • Representing booleans in Databases

    I have a question about how a boolean attribute should be represented in a database table. I have found that a value of false is equal to 0 and a value of true is equal to 1, so therefore, it is my contention that the corresponding column in the database table should be defined as a number rather than CHAR(1). For example, if I have an Employee class with a boolean attribute named isActive, I feel that the isActive column in the database should be defined as a Decimal(1,0) instead of a CHAR(1) to avoid having to write needless data conversion code. Anyway, before I try to defend my position to our Data Analysts, I wanted to get a feel for what the industry thinks on this issue. If you have any opinions, references, or documentation on this subject, I would greatly appreciate it. I would really like to have some good solid information on how this should be done. Thank you very much for your help.

    I might nit-pick a little and say that the value true was first, and is most commonly represented by a bit being turned on, and the value false was first and is most commonly represented by the bit being turned off.
    I honestly don't know how the various programming languages actually store this on/off information, it may be as bits, or int's. I would doubt there are any implementations that would store on/off using a fixed or variable character string.
    Many databases actually include a boolean data type, so for those databases this question is moot. For those that don't, I would suggest that you should consider a couple of issues when making your decision.
    1) The efficiency of storage in the database. For example when using varchar2 in Oracle there is overhead to hold the variable string size information. I have seen some people store the words 'false' and 'true' for boolean use (because it's an easy transformation in Java). But it's a poor choice from a database perspective. Overall storage is probably the #1 concern that will be expressed when using your scheme on a large database.
    2) The efficiency of retrieving from the database. Really an issue with the count and access frequency of the boolean values. This can be very hard to discern without having intimate knowledge of the database engine, and the application. So while it is a consideration, you may have to dig some to get the information you need.
    3) Be consistent. Often times people will do something quite different for a small, or throw away application, then they would for a large terabyte implementation. Not being consistent can waste hours of programming and user time trying to figure something out based on incorrect assumptions. I can't say this strongly enough.
    4) Whatever you choose, make sure that it works with all databases that you currently use, or that you might use in the future. Again, you want to be consistent across all databases. If there is a cool way to do this in Informix but it doesn't work in Oracle, then skip it and find something that works well in both. I would make sure it works at least with Oracle, Informix, DB2, DB2/UDB and SQL Server.
    Just some thoughts on the topic. Sorry I don't have a specific requirement that I can hand you. Good luck in your discussions.
    Joel

  • Unable to connect to Analysis Services 2012 via SSMS

    Hello. We have a fresh install of WS 2012 and SQL Server 2012 Standard. When connecting to Analysis Services with Management Studio, we get the following error:
    TITLE: Microsoft SQL Server Management Studio
    Error connecting to 'SERVERNAME'.
    ADDITIONAL INFORMATION:
    Method not found: 'Void Microsoft.AnalysisServices.Server.Connect(System.String, Boolean)'. (ObjectExplorer)
    BUTTONS:
    OK
    Advanced Information shows:
    ===================================
    Error connecting to 'SERVERNAME'.
    ===================================
    Method not found: 'Void Microsoft.AnalysisServices.Server.Connect(System.String, Boolean)'. (ObjectExplorer)
    Program Location:
       at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.SupportedServers.IsIMBIServer(SqlOlapConnectionInfoBase connectionInfo)
       at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.SupportedServers.GetHierarchyBuilder(SqlOlapConnectionInfoBase connectionInfo)
       at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorerControl.GetObjectBuilder(SqlOlapConnectionInfoBase ci)
       at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorerControl.BuildDataModel(SqlOlapConnectionInfoBase ci)
       at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorerControl.GetHierarchy(SqlOlapConnectionInfoBase ci, String displayName)
       at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ConnectToServer(UIConnectionInfo connectionInfo, IDbConnection liveConnection, Boolean validateConnection)
    Database Engine, Reporting Services and Integration Services work fine. Any idea what's wrong with Analysis Services component?

    I will reply to myself, that updating the SQL Server with latest updates solved the issue.

  • Help with EJB plz

    Hi,
    I'm new to EBJs and am playing with an entity bean pretty much identical to the one on the J2EE tutorial but the home interface does not compile and I've got no idea why. Would really appreciate your help.
    COMPILER COMPLAINT*****
    C:\j2sdkee1.3\nim\src\ejb\addresses>javac AddressesHome.java
    AddressesHome.java:7: cannot resolve symbol
    symbol : class Addresses
    location: interface AddressesHome
    public Addresses Create(String id, String firstname, String lastname, St
    ring address, int contactno) throws RemoteException, CreateException;
    ^
    AddressesHome.java:10: cannot resolve symbol
    symbol : class Addresses
    location: interface AddressesHome
    public Addresses FindByPrimaryKey(String id) throws FinderException, Rem
    oteException;
    ^
    2 errors
    HOME INTERFACE*****
    import java.util.Collection;
    import java.rmi.RemoteException;
    import javax.ejb.*;
    public interface AddressesHome extends EJBHome
         public Addresses Create(String id, String firstname, String lastname, String address, int contactno) throws RemoteException, CreateException;
         public Addresses FindByPrimaryKey(String id) throws FinderException, RemoteException;
         public Collection FindByLastName(String lastname) throws FinderException, RemoteException;
    ADDRESSESSBEAN CLASS*****
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    import javax.ejb.*;
    import javax.naming.*;
    public class AddressesBean implements EntityBean
         private String id;
         private String firstname;
         private String lastname;
         private String address;
         private int contactno;
         private Connection conn;
         private EntityContext context;
         private String dbName = "java:comp/env/jdbc/AddressesdB";
         public String ejbCreate(String id, String firstname, String lastname, String address, int contactno) throws CreateException
                   if(address == null || address.length() == 0)
                        throw new CreateException("You must specify an address");
                   try
                        insertRow(id, firstname, lastname, address, contactno);
                   catch(Exception e)
                        throw new EJBException("ejbCreate: " + e.getMessage());
                   this.id = id;
                   this.firstname = firstname;
                   this.lastname = lastname;
                   this.address = address;
                   this.contactno = contactno;
                   return id;
         public void changeAddress(String address)
              this.address = address;
         public String getAddress()
              return address;
         public void changeContactno(int contactno)
              this.contactno = contactno;
         public int getContactno()
              return contactno;
         public String getFirstname()
              return firstname;
         public String getLastname()
              return lastname;
         public String ejbFindByPrimaryKey(String primaryKey) throws FinderException
              boolean result;
              try
                   result = selectByPrimaryKey(primaryKey);
              catch(Exception e)
                   throw new EJBException("ejbFindByPrimaryKey: " + e.getMessage());
              if(result)
                   return primaryKey;
              else
                   throw new ObjectNotFoundException("Row for id " + primaryKey + " not found");
         public Collection ejbFindByLastName(String lastname) throws FinderException
              Collection result;
              try
                   result = selectByLastName(lastname);
              catch(Exception e)
                   throw new FinderException("ejbFindByLastName :" + e.getMessage());
              return result;
         public void ejbRemove()
              try
                   deleteRow(id);
              catch(Exception e)
                   throw new EJBException("ejbRemove : " + e.getMessage());
         public void setEntityContext(EntityContext context)
              this.context = context;
              try
                   makeConnection();
              catch(Exception e)
                   throw new EJBException("Unable to connect to database: " + e.getMessage());
         public void unsetEntityContext()
              try
                   conn.close();
              catch(Exception e)
                   throw new EJBException("unsetEntityContext: " + e.getMessage());
         public void ejbActivate()
              id = (String)context.getPrimaryKey();
         public void ejbPassivate()
              id = null;
         public void ejbLoad()
              try
                   loadRow();
              catch(Exception e)
                   throw new EJBException("ejbLoad: " + e.getMessage());
         public void ejbStore()
              try
                   storeRow();
              catch(Exception e)
                   throw new EJBException("ejbStore: " + e.getMessage());
         public void ejbPostCreate(String id, String firstname, String lastname, String address, boolean contactno)
         /****************************** DataBase Routines ******************************/
         private void makeConnection() throws NamingException, SQLException
              InitialContext ic = new InitialContext();
              DataSource ds = (DataSource) ic.lookup(dbName);
              conn = ds.getConnection();
         private void insertRow(String id, String firstname, String lastname, String address, int contactno) throws SQLException
              String insertStatement = "inset into ADDRESSES values (?, ?, ?, ?, ?)";
              PreparedStatement prepStmt = conn.prepareStatement(insertStatement);
              prepStmt.setString(1, id);
              prepStmt.setString(2, firstname);
              prepStmt.setString(3, lastname);
              prepStmt.setString(4, address);
              prepStmt.setDouble(5, contactno);
              prepStmt.executeUpdate();
              prepStmt.close();
         private void deleteRow(String id) throws SQLException
              String deleteStatement = "delete from ADDRESSES where id = ?";
              PreparedStatement prepStmt = conn.prepareStatement(deleteStatement);
              prepStmt.setString(1, id);
              prepStmt.executeUpdate();
              prepStmt.close();
         private boolean selectByPrimaryKey(String primaryKey) throws SQLException
              String selectStatement = "select id from ADDRESSES where id = ? ";
              PreparedStatement prepStmt = conn.prepareStatement(selectStatement);
              prepStmt.setString(1, primaryKey);
              ResultSet rs = prepStmt.executeQuery();
              boolean result = rs.next();
              prepStmt.close();
              return result;
         private Collection selectByLastName(String lastname) throws SQLException
              String selectStatement = "select id from ADDRESSES where lastname = ? ";
              PreparedStatement prepStmt = conn.prepareStatement(selectStatement);
              prepStmt.setString(1, lastname);
              ResultSet rs = prepStmt.executeQuery();
              ArrayList a = new ArrayList();
              while(rs.next())
                   String id = rs.getString(1);
                   a.add(id);
              prepStmt.close();
              return a;
         private void loadRow() throws SQLException
              String selectStatement = "select firstname, lastname, address, contactno from ADDRESSES where id = ?";
              PreparedStatement prepStmt = conn.prepareStatement(selectStatement);
              prepStmt.setString(1, this.id);
              ResultSet rs = prepStmt.executeQuery();
              if(rs.next())
                   this.firstname = rs.getString(1);
                   this.lastname = rs.getString(2);
                   this.address = rs.getString(3);
                   this.contactno = rs.getInt(4);
                   prepStmt.close();
              else
                   prepStmt.close();
                   throw new NoSuchEntityException("Row for id " + id + " not found in the dataBase");
         private void storeRow() throws SQLException
              String updateStatement = "update ADDRESSES set firstname = ?, lastname = ?, address = ? contactno = ? where id = ?";
              PreparedStatement prepStmt = conn.prepareStatement(updateStatement);
              prepStmt.setString(1, firstname);
              prepStmt.setString(2, lastname);
              prepStmt.setString(3, address);
              prepStmt.setInt(4, contactno);
              prepStmt.setString(5, id);
              int rowCount = prepStmt.executeUpdate();
              prepStmt.close();
              if(rowCount == 0)
                   throw new EJBException("Storing row for id " + id + " failed.");
    }

    EJB questions should be posted in the EJB forum! :=)
    I did find the compiler message a bit strange. Usually if I don't have a class defined it complains that it cannot find package_name.class_name (when I'm using packages for my own code).

  • Workflow, Form Manager and email question...

    Hi All,
    We have a client with 36,000 world-wide users of Form Manager. They need all 36,000 users to default to getting an email when a work item hits their worklist. The default is normally that this option be "un-checked"
    until each an every user goes to the Form Manager site, chooses
    "Preferences" and then "Workflow" and then places a check-mark beside
    "Send me an email when assigned a task".
    They can't depend on getting all 36,000 employees to go to Form Manager
    and do this, so a work item will surely get assigned to someone who
    hasn't done this, and will never know they got a work item in their
    worklist.
    Does anyone know how we can change the default for everyone so that this
    option is automatically "checked" for each of the 36,000 users?
    Thanks.

    Hello -
    Firstly you should go into the AdminUI component and make sure the email settings are correctly set there - the settings in the admin for email notifications will be applied to a new user. A new user is either a user who logs in for the first time or who is assigned work in a user qpac.
    Secondly for users who have already logged in you could write a simple db update statement to change all of the user's preferences. STMT would look like this:
    UPDATE tb_workflow_user SET email_task_assigned = 1
    There are other columns for the user preferences in that table as well. Also note that these fields may be of type boolean on databases which support it, others use a bit or short type.
    Good luck!
    Will@Adobe

  • Modeling a boolean value in an Oracle database

    I want to use a boolean type in my XML schema and need to know how best to map that to the database. I tried using a string, but I get an error in the update map for that.
    Any advice?
    Thanks,
    Jeff

    I still have not resolved how to do this.
    I want to have an IsActive flag on some of my records, and I would like to use xs:boolean to model this in the data returned from my DSP service. I have tried using Number(1) and char(1) as data types in Oracle, but DSP gives me a compile time error on the update function:
    {ld:CaseManagement/AppUsers}createAppUser : The update map does not support "CREATE" : Create is not possible for the update operation for ld:CaseManagement/Physical/APP_USER. ( The expression assigned to /APP_USER/IS_ACTIVE in the update to data service ld:CaseManagement/Physical/APP_USER does not match the expected type )     IDEXXDataServices/CaseManagement     AppUsers.ds     line 108     1212063467729     9920
    Is there a way to use xs:boolean in my XML Schema and map it directly to a physical source? If not, how can I add logic in DSP to calculate the appropriate value during an update operation? I see an update expression editor in other data services, but in the one with the error, the expression editor flashes, and then goes away, so I can't edit it.
    Thanks,
    Jeff
    Edited by jhoffmanme at 05/29/2008 5:44 AM

  • To display a VARCHAR field in database as select boolean checkbox

    Hi,
    i have a table in database having a VARCHAR2(1) field named IsActive with value 'Y' or 'N' , I need to display this field as select boolean check box in the JSF page
    using ADF Entity Object and ViewObject. We have followed the following method for displaying this field as select boolean check box.
    1. Changed the datatype of the IsActive field in the Entity Object as Boolean and the database column type as Varchar2(10)
    2. we have edited the query using case when IsActive='Y' then 1 else 0 end .
    3.and converted the IsActive inputtext to select boolean checkbox.
    Thus we where able to display this field as select boolean check box but the problem is that we where not able to insert the data as 'Y' or 'N' using this method.
    Please help us whether the method we are following is correct or is there any other method to insert and display the similar fields like IsActive as select boolean check box in ADF
    Thanks in Advance
    Anitha

    Anitha,
    Create a transient boolean attribute on your EO. Write the getter to return true/false if the real attribute is Y/N. Write the setter to do the converse. Bind the transient attribute to the checkbox.
    John

  • I have boolean type of value in the database, how to get it as true or fals

    Hi friends,
    I have login page in that only admin can access next page after login. First my problem is only admin must be logged in, so i have used one column named admin, which is nothing but it is BIT type of column. So if it is true then it must allow the admin, otherwise if it is false then it must not redirect to that page. So how can i get that column value whether it is true or false. I have used this method to get the value.
    boolean ok = getBoolean("Admin");// This isnothing but getting column Admin which is of type boolean.
    if(ok==true){
    return "adminPage";
    }Please help me out from this problem. Please give me a suggestion.
    Thanking You in Advance.

    Hi There,
    Normally a database stores the boolean value as a 0 or a 1. you may have to check for that or convert the 0,1 to true or false and then check for it.
    Hope it helps
    K

  • Invoking a Database boolean Function from Java

    Hi,
    I have the following boolean database function --
      FUNCTION isPositive(p_count NUMBER) RETURN BOOLEAN
      IS
      BEGIN
        IF p_count < 0 THEN
          return false;
        END IF;
        return true;
      END;I read somewhere that CallableStatement doesn't support the boolean function.
    I tried to use CallableStatement to invoke the above function as follows --
        String sql = "begin ? := helperpkg.isPositive(?); end;";
        CallableStatement cs = jdbcConn.prepareCall(sql);
        cs.registerOutParameter(1, java.sql.Types.BOOLEAN);
        cs.setInt(2, -5);
        cs.execute();
        return cs.getBoolean(1);But it gave me the exception --
    java.sql.SQLException: Invalid column type
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
            at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:6164)
            at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:244)
            at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:393)
            at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:462)
            at DBConnector.invokeFunction(DBConnector.java:63)
            at DBConnector.main(DBConnector.java:21)Please advice.
    Thanks

    I read somewhere that CallableStatement doesn't
    support the boolean function.http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/apxref.htm#BABFECBJ
    Best regards
    Maxim

  • Input the data in to the grid without saving it to the  database

    <PRE lang=jsp id=pre2 style="MARGIN-TOP: 0px" nd="109"><%@ taglib uri="/WEB-INF/tags/datagrid.tld" prefix="grd" %>
    <%@ page import="java.sql.Connection" %>
    <%@ page import="java.sql.DriverManager" %>
    <%@ page import="java.sql.SQLException" %>
    <%@ page import="com.freeware.gridtag.*" %>
    <%
    int intCurr = 1;
    int intSortOrd = 0;
    String strTmp = null;
    String strSQL = null;
    String strSortCol = null;
    String strSortOrd = "ASC";
    boolean blnSortAsc = true;
    strSQL = "SELECT CLICORPORATION, CLICLIENT, CLIDESCRIPTION, " +
    "CLIENABLED, CLIUPDSTAMP FROM CLIENTMASTER ";
    Connection objCnn = null;
    Class objDrvCls = null;
    objDrvCls = Class.forName("oracle.jdbc.driver.OracleDriver");
    objCnn = DriverManager.getConnection("<A class=iAs style="FONT-WEIGHT: normal; FONT-SIZE: 100%; PADDING-BOTTOM: 1px; COLOR: darkgreen; BORDER-BOTTOM: darkgreen 0.07em solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="#" target=_blank itxtdid="3346226">jdbc</A>:oracle:thin:@Host:port:sid",
    "cashincpri", "cashincpri");
    if (objDrvCls != null) objDrvCls = null;
    strTmp = request.getParameter("txtCurr");
    try
    if (strTmp != null)
    intCurr = Integer.parseInt(strTmp);
    catch (NumberFormatException NFEx)
    strSortCol = request.getParameter("txtSortCol");
    strSortOrd = request.getParameter("txtSortAsc");
    if (strSortCol == null) strSortCol = "CLICLIENT";
    if (strSortOrd == null) strSortOrd = "ASC";
    blnSortAsc = (strSortOrd.equals("ASC"));
    %>
    <html>
    <head>
    <title>Grid Tag Demonstration</title>
    <link REL="StyleSheet" HREF="css/GridStyle.css">
    <script LANGUAGE="javascript">
    function doNavigate(pstrWhere, pintTot)
    var strTmp;
    var intPg;
    strTmp = document.frmMain.txtCurr.value;
    intPg = parseInt(strTmp);
    if (isNaN(intPg)) intPg = 1;
    if ((pstrWhere == 'F' || pstrWhere == 'P') && intPg == 1)
    alert("You are already viewing first page!");
    return;
    else if ((pstrWhere == 'N' || pstrWhere == 'L') && intPg == pintTot)
    alert("You are already viewing last page!");
    return;
    if (pstrWhere == 'F')
    intPg = 1;
    else if (pstrWhere == 'P')
    intPg = intPg - 1;
    else if (pstrWhere == 'N')
    intPg = intPg + 1;
    else if (pstrWhere == 'L')
    intPg = pintTot;
    if (intPg < 1) intPg = 1;
    if (intPg > pintTot) intPg = pintTot;
    document.frmMain.txtCurr.value = intPg;
    document.frmMain.submit();
    function doSort(pstrFld, pstrOrd)
    document.frmMain.txtSortCol.value = pstrFld;
    document.frmMain.txtSortAsc.value = pstrOrd;
    document.frmMain.submit();
    </script>
    </head>
    <body>
    <h2>Grid Example</h2>
    <form NAME="frmMain" METHOD="post">
    <grd:dbgrid id="tblStat" name="tblStat" width="100" pageSize="10"
    currentPage="<%=intCurr%>" border="0" cellSpacing="1" cellPadding="2"
    dataMember="<%=strSQL%>" dataSource="<%=objCnn%>" cssClass="gridTable">
    <grd:gridpager imgFirst="images/First.gif" imgPrevious="images/Previous.gif"
    imgNext="images/Next.gif" imgLast="images/Last.gif"/>
    <grd:gridsorter sortColumn="<%=strSortCol%>" sortAscending="<%=blnSortAsc%>"/>
    <grd:rownumcolumn headerText="#" width="5" HAlign="right"/>
    <grd:imagecolumn headerText="" width="5" HAlign="center"
    imageSrc="images/Edit.gif"
    linkUrl="javascript:doEdit('{CLICORPORATION}', '{CLICLIENT}')"
    imageBorder="0" imageWidth="16" imageHeight="16"
    alterText="Click to edit"/>
    <grd:textcolumn dataField="CLICLIENT" headerText="Client"
    width="10" sortable="true"/>
    <grd:textcolumn dataField="CLIDESCRIPTION" headerText="Description"
    width="50" sortable="true"/>
    <grd:decodecolumn dataField="CLIENABLED" headerText="Enabled" width="10"
    decodeValues="Y,N" displayValues="Yes,No" valueSeperator=","/>
    <grd:datecolumn dataField="CLIUPDSTAMP" headerText="Last Updated"
    dataFormat="dd/MM/yyyy HH:mm:ss" width="20"/>
    </grd:dbgrid>
    <input TYPE="hidden" NAME="txtCurr" VALUE="<%=intCurr%>">
    <input TYPE="hidden" NAME="txtSortCol" VALUE="<%=strSortCol%>">
    <input TYPE="hidden" NAME="txtSortAsc" VALUE="<%=strSortOrd%>">
    </form>
    </body>
    </html>
    <%
    try
    if (objCnn != null)
    objCnn.close();
    catch (SQLException SQLExIgnore)
    if (objCnn != null) objCnn = null;
    %>
    </PRE>
    by using this code we will get the gide.
    but the problem is when we are inserting the new record after click to save the record first saves the data in the Db and then it appears on the grid.
    Is it possible to do reverse of the above :
    first it comes to the grid and then after click to save it save to the database.
    please help me
    Regards,
    imran

    Hi Yamini,
    What do you mean by without query region here? Do you wish to implement the complete search/result functionality without using the Query page? Or your question already answered. Kindly confirm.
    Regards
    Sumit

  • Unable to save Sequence value to Database

    Hi,
    I am trying to pupulate a sequence value so that I can use it as primary key along with the combination of other columns later. My problem is that the sequence value is getting populated on the page with the right value, But is not getting saved to the database. The Column is there in the VO. The column is blank on the table. When I print it(System.out.println("Seq=" + xSeq.getText(pageContext));), the value is null. Can anyone please advice what I am doing wrong OR if I am missing anything here.
    Thanks
    Ali
    My CO file:
    ============
    package lac.oracle.apps.lac.jobperf.server.webui;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OADialogPage;
    import oracle.apps.fnd.framework.webui.TransactionUnitHelper;
    import oracle.jbo.domain.Number;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
    import oracle.apps.fnd.framework.webui.beans.layout.OAMessageComponentLayoutBean;
    import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
    import com.sun.java.util.collections.HashMap;
    import oracle.bali.share.util.IntegerUtils;
    import oracle.apps.fnd.framework.server.OADBTransaction;
    * Controller for ...
    public class ReviewCreateCO extends OAControllerImpl
    public static final String RCS_ID="$Header$";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    * Layout and page setup logic for a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    OAApplicationModule am; // dave
    OADBTransaction oadbxn; // dave
    oracle.jbo.domain.Number Seq;
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    // Always call this first
    super.processRequest(pageContext, webBean);
    am = pageContext.getApplicationModule(webBean); // dave
    oadbxn = am.getOADBTransaction(); // dave
    OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
    OAMessageComponentLayoutBean mainRn = (OAMessageComponentLayoutBean)pageLayout.findIndexedChildRecursive("MainRN");
    // If isBackNavigationFired = false, we are here after a valid navigation
    // (the user selected the Create Review button) and we should proceed
    // normally and initialize a new Review.
    if (!pageContext.isBackNavigationFired(false))
    // We indicate that we are starting the create transaction(this
    // is used to ensure correct Back button behavior).
    TransactionUnitHelper.startTransactionUnit(pageContext,"jobperfCreateTxn");
    // This test ensures that we don't try to create a new review if we
    // had a JVM failover, or if a recycled application module is activated
    // after passivation. If this things happen, BC4J will be able to find
    // the row you created so the user can resume work.
    if (!pageContext.isFormSubmission())
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    // String Seq = (String)oadbxn.getValue("Seq");
    oracle.jbo.domain.Number Seq = oadbxn.getSequenceValue("lac.LAC_CM_PERF_REVIEW_SEQ");
    OAMessageStyledTextBean xSeq = (OAMessageStyledTextBean)mainRn.findIndexedChildRecursive("Seq");
    xSeq.setText(Seq.toString());
    am.invokeMethod("createReview",null);
    // Initialize the ApplicationpropertiesVO for PPR.
    // am.invokeMethod("init");
    else
    if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"jobperfCreateTxn", true))
    // We got here through some use of the browser "Back" button, so we
    // want to display a stale data error and disallow access to the page.
    // if this were a real application, we would propably display a more
    // context-specific message telling the user she can't use the browser
    //"Back" button and the "Create" page. Instead, we wanted to illustrate
    // how to display the Applications standard NAVIGATION ERROR message.
    OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
    pageContext.redirectToDialogPage(dialogPage);
    } // end processRequest()
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    {    //super.processFormRequest(pageContext, webBean);
    // Always call this first.
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
    OAMessageComponentLayoutBean mainRn = (OAMessageComponentLayoutBean)pageLayout.findIndexedChildRecursive("MainRN");
    // Pressing the "Apply" button means the transaction should be validated
    // and committed.
    // OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
    // String Seq = SeqText.getText(pageContext);
    oadbxn.putValue("Seq", Seq);
    am = pageContext.getApplicationModule(webBean);
    oadbxn = am.getOADBTransaction();
    if (pageContext.getParameter("Apply") != null)
    // Generally in the tutorial application and the labs, we've illustrated
    // all BC4J interaction on the server (except for the AMs, of course). Here,
    // we're dealing with the VO directly so the comments about the reasons
    // why we're obtaining values from the VO and not the request make sense
    // in context.
    OAViewObject vo = (OAViewObject)am.findViewObject("jobperfVO1");
    // Note that we have to get this value from the VO because the EO will
    // assemble it during its validation cycle.
    // For performance reasons, we should generally be calling getEmployeeName()
    // on the EmployeeFullVORowImpl object, but we don't want to do this
    // on the client so we're illustrating the interface-appropriate call. If
    // we implemented this code in the AM where it belongs, we would use the
    // other approach.
    String employeeName = (String)vo.getCurrentRow().getAttribute("FullName");
    // We need to get a String so we can pass it to the MessageToken array below. Note
    // that we are getting this value from the VO (we could also get it from.
    // the Bean as shown in the Drilldwon to Details lab) because the item style is messageStyledText,
    // so the value isn't put on the request like a messaqeTextInput value is.
    String employeeNumber = (String)vo.getCurrentRow().getAttribute("EmployeeNumber");
    //ma String employeeNum = String.valueOf(employeeNumber.intValue());
    //ma Number employeeNumber = (Number)vo.getCurrentRow().getAttribute("EmployeeNumber");
    //ma String employeeNum = String.valueOf(employeeNumber.intValue());
    // Simply telling the transaction to commit will cause all the Entity Object validation
    // to fire.
    // Note: there's no reason for a developer to perform a rollback. This is handled by
    // the framework if errors are encountered.
    OAMessageStyledTextBean xSeq = (OAMessageStyledTextBean)mainRn.findIndexedChildRecursive("Seq");
    System.out.println("Seq=" + xSeq.getText(pageContext));
    am.invokeMethod("apply");
    // Indicate that the Create transaction is complete.
    TransactionUnitHelper.endTransactionUnit(pageContext, "jobperfCreateTxn");
    // Assuming the "commit" succeeds, navigate back to the "Search" page with
    // the user's search criteria intact and display a "Confirmation" message
    // at the top of the page.
    MessageToken[] tokens = { new MessageToken("EMP_NAME", employeeName),
    new MessageToken("EMP_NUMBER", employeeNumber) };
    OAException confirmMessage = new OAException("PER", "LAC_FWK_TBX_T_EMP_CREATE_CONF", tokens,
    OAException.CONFIRMATION, null);
    // Per the UI guidelines, we want to add the confirmation message at the
    // top of the search/results page and we want the old search criteria and
    // results to display.
    pageContext.putDialogMessage(confirmMessage);
    HashMap params = new HashMap(1);
    // Replace the current employeeNumber request parameter value with "X"
    params.put("employeeNumber", "employeeNumber");
    // IntegerUtils is a handy utility
    params.put("employeeNumber",IntegerUtils.getInteger(5));
    pageContext.forwardImmediately(
    "OA.jsp?page=/lac/oracle/apps/lac/jobperf/webui/jobperfPG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    params, //null,
    false, // retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_YES);
    else if (pageContext.getParameter("Cancel") != null)
    am.invokeMethod("rollbackReview");
    // Indicate that the Create transaction is complete.
    TransactionUnitHelper.endTransactionUnit(pageContext, "jobperfCreateTxn");
    pageContext.forwardImmediately("OA.jsp?page=/lac/oracle/apps/lac/jobperf/webui/jobperfPG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    false, // retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    } // end processFormRequest()
    }

    Hi Tapash,
    Thanks for all of you guys(Tapash/Sumit/user550094) help. The sequence is working and also populating the values in the table when I do not have any validation checks imposed on it.
    If I add any validations as mentioned in the exercise for create page where it checks if the sequence can be updated while null and so on... and throws appropriate exception. I get error. That is the code that I mentioned above.
    Here is the validation code for EOImpl:
    As mentioned below in order for the code to compile and work I had to comment the "throw new OAAttrvalException". If I uncomment the
    "throw new OAAttrvalException" part, it gives me the following error while compiling:
    "Error(796,13): method getPrimarykey not found in class lac.oracle.apps.lac.jobperf.schema.server.jobperfEOImpl"
    public void setSeq(Number value)
    // Because of the declaritive validation that you specified for this attribute,
    // BC4J validates that this can be updated only on a new line, and that this,
    // mandatory attribute cannot be null. This code adds the additional check
    // of only allowing an update if the value is null to prevent changes while
    // the object is in memory.
    if (getSeq() != null)
    /* throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), //getSeq(), // EO name
    getPrimarykey(), // EO PK
    "Seq", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "FWK_TBX_T_EMP_ID_NO_UPDATE"); // Message name */
    if (value != null)
    // Seq ID must be unique. To verify this, check both the
    // entity cache and the database. In this case, it's appropriate
    // to use findByPrimaryKey() because you're unlikely to get a match, and
    // and are therefore unlikely to pull a bunch of large objects into memory.
    // Note that findByPrimaryKey() is guaranteed to check all employees.
    // First it checks the entity cache, then it checks the database.
    OADBTransaction transaction = getOADBTransaction();
    Object[] employeeKey = {value};
    EntityDefImpl empDefinition = jobperfEOImpl.getDefinitionObject();
    jobperfEOImpl Seq =
    (jobperfEOImpl) empDefinition.findByPrimaryKey(transaction, new Key(employeeKey));
    if (Seq != null)
    /* throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // .getSeq(), // EO name
    getPrimaryKey(), // EO PK
    "Seq", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "FWK_TBX_T_EMP_ID_UNIQUE"); // Message name */
    // Note that this is the point at which the value is actually set on the EO cache
    // (during the scope of setAttributeInternal processing). If you don't make this
    // call after you perform your validation, your value will not be set correctly.
    // Also, any declarative validation that you define for this attribute is executed
    // within this method.
    setAttributeInternal(SEQ, value);
    } // end SetSeq
    I am sorry if I have confused you. I really did not mean to do it.
    Thanks,
    Ali

  • The database structure has been modified - how to check if it happend?

    Hello,
    I have a question. How to check if the database structure has been modified? I know that there is shown a messagebox after creating table and adding some fields, but sometimes this message appear after some seconds. The problem is that I want to create table and UDO for this table, and until database structure is not modified I got an error message. If I wait and DB strucuture modifies then UDO is creating correctly.
    My question is - does anyone know how to check if database structure has been modified?
    Regards,
    Hmg

    Hi Szymon,
    I guess you are stuck up in a kinda scenario, where in, you will be populating a form with values, before the structure modifies, if this is going to be your problem, I can help you out with a work around.
    In the beginning of the process, before the creation of the UDO or tables, set a boolean value to false, and once all UDO's and Tables are created, only then, should you make it true and only after the boolean becomes true, you should proceed with populating the values from the screen.
    I really ament sure what your problem is, but one of my guys faced this problem, I then, thought even you might have a similar problem.
    Satish.

  • Business rule in MDS 2012 error: A database error has occurred. Contact your system administrator.

    I get the following information in my MDS log as well as the above error message when I execute a business rule that has a condition of AND and an Action of Attribute must be unique in combination with 2 other attributes. 
    I'm running SQL Server 2012 11.0.3000
    MDS database version 11.1.0.0
    Any ideas?
    MDS Error: 0 : SqlException message: A database error has occurred. Contact your system administrator.
       at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.HandleExceptions(Exception ex)
       at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.ExecuteDataSet(String spName, CloseConnectionBehavior closeBehavior, Object[] parameterValues)
       at Microsoft.MasterDataServices.Core.DataAccess.MasterDataAccess.<>c__DisplayClass5.<ValidateEntityMembers>b__4()
       at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.ExecuteMethodWithDeadlockProtection(MethodDelegate method)
       at Microsoft.MasterDataServices.Core.BusinessLogic.Validations.ValidateMembers(Int32 versionId, Identifier entityIdentifier, IList`1 memberIds, RequestContext context, OperationResult results)
       at Microsoft.MasterDataServices.Core.BusinessLogic.Validations.Process(ValidationProcessCriteria criteria, Boolean commitVersion, Boolean validateEntityAsync, Boolean returnValidationResults, RequestContext context, OperationResult results)
    SQL Error Debug Info: Number: 208, Message: Invalid object name 'cteDuplicates0a070e37b106b9e3efe35a455076efa7'., Server: SQLRS-01, Proc: udp_SYSTEM_3_38_CHILDATTRIBUTES_ProcessRules, Line: 230
    SQL Error Debug Info: Number: 266, Message: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1., Server: SQLRS-01, Proc: udp_SYSTEM_3_38_CHILDATTRIBUTES_ProcessRules, Line: 230
    SQL Error Debug Info: Number: 266, Message: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1., Server: SQLRS-01, Proc: , Line: 0
    SQL Error Debug Info: Number: 266, Message: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1., Server: SQLRS-01, Proc: udpBusinessRule_AttributeMemberController, Line: 0
    SQL Error Debug Info: Number: 266, Message: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1., Server: SQLRS-01, Proc: udpValidateMembers, Line: 0
        DateTime=2013-08-15T13:25:15.6684023Z
    MDS Error: 0 : <ArrayOfError xmlns="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <Error>
        <Code>208</Code>
        <Context i:nil="true" />
        <Description>A database error has occurred. Contact your system administrator.</Description>
      </Error>
    </ArrayOfError>
        DateTime=2013-08-15T13:25:15.7152026Z

    OK I bit the bullet and contacted support on this one.
    There is a known issue with MDS 2012 and business rules with a combination of "must be unique" attributes. If you do not list the attributes in the same order that they were created you will get the generic error I cited. At first they told me it must be
    in the same order the attributes are in and that worked on one entity but not the other. The difference was that in the second entity I previously rearranged the attributes in question. Once I changed the order in the business rule to reflect the *original*
    order it worked like a champ.
    Hopefully this helps save someone some time and money.

  • Can't connect a servlet to a mysql database (jdbc)

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class LoginServletJDBC extends HttpServlet{
         public void doGet(HttpServletRequest request,HttpServletResponse response)
         throws ServletException,IOException{
              sendLoginForm(response,false);     }
         public void sendLoginForm(HttpServletResponse response,boolean error)
         throws ServletException,IOException{
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html><head>");
              out.println("<title>Login</title>");
              out.println("</head>");
              out.println("<body>");
              out.println("<center>");
              if(error)
                   out.println("<b>Failed login. Please try again</b>");
              out.println("<br><br>");
              out.println("<h2>Login page</h2>");
              out.println("<br>Please enter your username and password");
              out.println("<br><br>");
              out.println("<form method=post>");
              out.println("<table>");
              out.println("<tr>");
              out.println("<td>Username : </td>");
              out.println("<td><input type=text name=userName></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td>Password : </td>");
              out.println("<td><input type=password name=password></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td align=right colspan=3>");
              out.println("<input type=submit value=Login></td>");
              out.println("</tr>");
              out.println("</table>");
              out.println("</form>");
              out.println("</center>");
              out.println("</body></html>");
    public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException,IOException{
              String userName = request.getParameter("userName");
              String password = request.getParameter("password");
              if(login(userName,password)){
                   RequestDispatcher rd = request.getRequestDispatcher("AnotherServlet");
                   rd.forward(request,response);
              else{
                   sendLoginForm(response,true);
         boolean login(String userName,String password){
              try{
                   String url = "jdbc:mysql://localhost:3306/Users";
                   Class.forName("com.mysql.jdbc.Driver");
                   Connection con = DriverManager.getConnection(url,"root","");
                   //System.out.println("got connection");
                   Statement s = con.createStatement();
                   String sql = "select userName from Users where userName='"+userName+"and password='"+password+"';";
                   ResultSet rs = s.executeQuery(sql);
                   if(rs.next()){
                        rs.close();
                        s.close();
                        con.close();
                        return true;
                   rs.close();
                   s.close();
                   con.close();
              catch(ClassNotFoundException e){
                   System.out.println(e.toString());
              catch(SQLException e){
                   System.out.println(e.toString());
              catch(Exception e){
                   System.out.println(e.toString());
              return false;
    }so ...
    here i'm trying to connect to Users mysql database (i use Tomcat 4.1 and mysql servers and clients 4.0.1-alpha)
    where is the problem ? when i run this servlet (http://localhost:8080/example/servlet/LoginServletJDBC ) it works ;
    BUT when i type an username and a password (any user&pass) my servlet doesn't connect to the database (become a infinite loop without output ; i mean no any errors and exceptions)
    i try other think : i changed the database with unexisting database and the result was that i was expected (Unknow database 'unexistingdatabase' )
    what i miss ?
    please... can anyone help me...
    thank`s in advance

    The wireless security setting that the Actiontec modem/router is using may be different...and not compatible....than the setting that the Comcast product was using.
    If you think that might the case, and you have the time to troubleshoot......
    Temporarily, turn off the wireless security on the Actiontec modem/router
    Reset an AirPort Express back to default settings, then see if it will connect using no security and allow an Internet connection when you do the Ethernet port test in the post above again.
    If the AirPort Express cannot connect correctly using no security on the wireless network.....then it is a no brainer to know that it will never connect when security is enabled.  So, if the AirPort will not connect using no security, you may have an incompatibility issue between the Actiontec and Apple products.
    However, if the AirPort Express connects OK with no security, then this tells you that you will need to use a different setting for security on the Actiontec...the same that the Comcast router was using before.....so the Express will have a better chance of connecting.
    That setting would be something like WPA/WPA2 Personal, or the same setting stated another way would be WPA-PSK-TKIP.

  • Upload multiple files WITH correct pairs of form fields into Database

    In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
    INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
    INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
    INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
    However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
    if(item.isFormField()){
    }else{
    }I seems to be restricted from this structure.
    The jsp form page
    <input type="text" name="description1" value="" />
    <input type="file" name="sourcefile" value="" />
    <input type="text" name="description2" value="" />
    <input type="file" name="sourcefile" value="" />The Servlet file
    package Upload;
    import sql.*;
    import user.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Date;
    import java.util.List;
    import java.util.Iterator;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.*;
    public class UploadFile extends HttpServlet {
    private String fs;
    private String category = null;
    private String realpath = null;
    public String imagepath = null;
    public PrintWriter out;
    private Map<String, String> formfield = new HashMap<String, String>();
      //Initialize global variables
      public void init(ServletConfig config, ServletContext context) throws ServletException {
        super.init(config);
      //Process the HTTP Post request
      public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        Thumbnail thumb = new Thumbnail();
        fs = System.getProperty("file.separator");
        this.SetImagePath();
         boolean isMultipart = ServletFileUpload.isMultipartContent(request);
         if(!isMultipart){
          out.print("not multiple part.");
         }else{
             FileItemFactory factory = new DiskFileItemFactory();
             ServletFileUpload upload = new ServletFileUpload(factory);
             List items = null;
             try{
                items = upload.parseRequest(request);
             } catch (FileUploadException e) {
                e.printStackTrace();
             Iterator itr = items.iterator();
             while (itr.hasNext()) {
               FileItem item = (FileItem) itr.next();
               if(item.isFormField()){
                  String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
                  formfield.put(item.getFieldName(),formvalue);
                  out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
               }else{
                 String itemName = item.getName();
                 String filename = GetTodayDate() + "-" + itemName;
                 try{
                   new File(this.imagepath + formfield.get("category")).mkdirs();
                   new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
                   //Save the file to the destination path
                   File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
                   item.write(savedFile);
                   thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
                   DBConnection db = new DBConnection();
                   String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
                   db.SelectQuery(sql);
                    while(db.rs.next()){
                      int cat_id = db.rs.getInt("id");
                      sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
                      out.println(sql);
                      db.RunQuery(sql);
                 } catch (Exception e){
                    e.printStackTrace();
            HttpSession session = request.getSession();
            UserData k = (UserData)session.getAttribute("userdata");
            k.setMessage("File Upload successfully");
            response.sendRedirect("./Upload.jsp");
      //Get today date, it is a test, actually the current date can be retrieved from SQL
      public String GetTodayDate(){
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        String today = format.format(new Date());
        return today;
      //Set the current RealPath which the file calls for this file
      public void SetRealPath(){
        this.realpath = getServletConfig().getServletContext().getRealPath("/");
      public void SetImagePath(){
        this.SetRealPath();
        this.imagepath = this.realpath + "images" +fs;
    }Can anyone give me some code suggestion? Thx.

    When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
    In any case you may look at how you are Uploading Multiple Files with mod_plsql.

Maybe you are looking for