Dependant lovs in jsp with mysql data

hi to all.
here is my doubt
How to create dependant dynamic list of values in jsp where the data comes from mysql tables.(I mean i am storing all the details in mysql tables using foreign keys etc..).
Ex.:country--->state--->district--->city--->
we will be having this in most of the sites in general.
Hope u got what i am looking for
Expecting a very quick and excellent answer.
thank you

Within jsp pages it is not possible to have the comboboxes dynamically updated without intervention to either refresh the page with the new data or use java script.
I had a similar problem which i resolved with java script :
Interactive combo boxes on jsp
Have a look at this thread for more info.

Similar Messages

  • How to handle html:multibox in jsp with ADF Data Binding

    Hi,
    I like to use html:multibox feature in my jsp with ADF Data Binding. I am able to retrieve checked values in the DataForwardAction form. However, when the page is refreshed, the checkboxes are not persistent and yet an error showing
    "JBO-25009: unable to create object type ....oracle.jbo.domain.Array" appears.
    Here is my jsp code:
    <c:forEach var="type" items="${bindings.SystemTypeView1.rangeSet}">
    <c:if test="${Row['SystemGroup'] == type['SystemGroup']}">
    <br>
    <html:multibox property="selectedSystemType">
    <c:out value="${type.SystemType}"/>
    </html:multibox>
    <c:out value="${type.TypeDesc}"/>
    </c:if>
    </c:forEach>
    Can anyone tell me how to handle html:multibox with ADF Data Binding and make the checkboxes persistent.

    Generally this can be done.
    I see a problem with your use case, which has nothing to do with jdev or java:
    How do you identify the user when he comes back to finish the form?
    For this you can't use information like session cookie or IP address because they change.
    So you have to save some information about the user which lets you identify him when he comes back. All other requirements can be implemented by ADF.
    Timo

  • JPA with MySQL-Data-Source

    Hello Forum,
    I have a question regarding usage of a MySQL-Data-Source in combination with JPA
    on the SAP NetWeaver Application Server, Java ™ EE 5 Edition.
    I have setup a custom datasource like explained in paper:
    "Working with Database Tables, DataSources and JMS Resources"
    - registered the database driver via telnet (Using mysql-connector-java-5.0.3-bin.jar)
    - created the data-sources.xml file underneath the META-INF dir of the EAR project
    [code]
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE data-sources SYSTEM "data-sources.dtd" >
    <data-sources>
      <data-source>
        <data-source-name>titan_cruises_ds</data-source-name>
        <driver-name>mysql-connector-java-5.0.3-bin.jar</driver-name>
         <init-connections>1</init-connections>
         <max-connections>10</max-connections>
         <max-time-to-wait-connection>60</max-time-to-wait-connection>
         <expiration-control>
              <connection-lifetime>600</connection-lifetime>
              <run-cleanup-thread>60</run-cleanup-thread>
         </expiration-control>
         <sql-engine>native_sql</sql-engine>
        <jdbc-1.x>
          <driver-class-name>com.mysql.jdbc.Driver</driver-class-name>
          <url>jdbc:mysql://ourHost.internal.com:3306/practise_titan_cruises</url>
          <user-name>myUser</user-name>
          <password>myPass</password>
        </jdbc-1.x>
      </data-source>
    </data-sources>
    [/code]
    After that I manually created the persistence.xml underneath the META-INF dir of the EJB project.
    [code]
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
         <persistence-unit name="titan_cruises_pu">
              <jta-data-source>titan_cruises_ds</jta-data-source>
         </persistence-unit>
    </persistence>
    [/code]
    After that I created the Entity named "Cabin" and the corresponding table within the db.
    Entity code:
    [code]
    package de.collogia.beans.pojo.ship;
    import java.io.IOException;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.Table;
    This persisted POJO class models the cabin data.
    <p>
    In this class persistence annotations are placed on the getter methods
    of the attributes. This tells the persistence manager to access them
    via the corresponding get- and set-Methods.</p>
    (Unfortunately this does not work on NetWeaver and I had to place them
    on field level aggain...)
    @author Henning Malzahn ([email protected])
    svn-revision:         $Rev:: 670                                           $:
    svn-lasted-edited-by: $Author:: henning                                    $:
    svn-last-changed:     $Date:: 2007-02-21 21:49:51 +0100 (Wed, 21 Feb 2007) $:
    @Entity
    @Table(name = "cabin")
    public class Cabin implements Serializable {
        /** The generated serial version UID used for serialization. */
        private static final long serialVersionUID = -8522497314498903378L;
        /** The actual version number of this class used for serialization. */
        private static int actualVersion = 1;
        /** The cabin's id. */
        @Id
        @GeneratedValue
        @Column(name = "id")
        private long id;
        /** The cabin's name */
        @Column(name = "name")
        private String name;
        /** The cabin's deck level */
        @Column(name = "deck_level")
        private int deckLevel;
        /** The cabin's ship id */
        @Column(name = "ship_id")
        private int shipId;
        /** The cabin's bed count */
        @Column(name="bed_count")
        private int bedCount;
    /---- Serialization/ Deserialization methods -/
    Method that is responsible for deserialization of the object.
    @param in The <code>ObjectInputStream</code> object to read
              the data from.
    @throws IOException That may occur when reading from the
                        <code>ObjectInputStream</code> object
    @throws ClassNotFoundException That may occur when invoking the default
                                   deserialization mechanism.
        private void readObject(final java.io.ObjectInputStream in)
            throws IOException, ClassNotFoundException {
            /* Invoke default deserialization mechanism. */
            in.defaultReadObject();
            /* Read the actual version number of the class. */
            actualVersion =  in.readInt();
        } // End of readObject()
    Method that is responsible for serialization of the object.
    @param out The <code>ObjectOutputStream</code> object to write
               the data to.
    @throws IOException That may occur when writing to the
                        <code>ObjectOutputStream</code> object.
        private void writeObject(final java.io.ObjectOutputStream out)
            throws IOException {
            /* Invoke default serialization mechanism. */
            out.defaultWriteObject();
            /* Write the actual version number of the class. */
            out.writeInt(actualVersion);
        } // End of writeObject()
    /---- Defining constructors -/
    Private default constructor.
        private Cabin() {
        } // End of default constructor
    Full constructor.
    @param name The cabin's name.
    @param deckLevel The cabin's deck level.
    @param shipId The cabin's ship id.
    @param bedCount The cabin's bed count.
        public Cabin(final String name,
                     final int deckLevel,
                     final int shipId,
                     final int bedCount) {
            this.name = name;
            this.deckLevel = deckLevel;
            this.shipId = shipId;
            this.bedCount = bedCount;
        } // End of full constructor
    /---- Overridden class methods -/
    Returns a string representation of the cabin's data.
    @see java.lang.Object#toString()
        @Override
        public String toString() {
            StringBuffer strBuf = new StringBuffer();
            strBuf.append(this.name);
            strBuf.append("\n");
            strBuf.append(this.deckLevel);
            strBuf.append("\n");
            strBuf.append(this.shipId);
            strBuf.append("\n");
            strBuf.append(this.bedCount);
            return strBuf.toString();
        } // End of toString()
    /---- Defining instance methods -/
    Get method for the member "<code>id</code>".
    @return Returns the id.
        public long getId() {
            return this.id;
    Set method for the member "<code>id</code>".
    HTDODO hm: Check whether it is possible to have setId method
    using private accesss level with NetWeaver JPA-Provider!
    @param id The id to set.
        private void setId(final long id) {
            this.id = id;
    Get method for the member "<code>name</code>".
    @return Returns the name.
        public String getName() {
            return this.name;
    Set method for the member "<code>name</code>".
    @param name The name to set.
        public void setName(final String name) {
            this.name = name;
    Get method for the member "<code>deckLevel</code>".
    @return Returns the deckLevel.
        public int getDeckLevel() {
            return this.deckLevel;
    Set method for the member "<code>deckLevel</code>".
    @param deckLevel The deckLevel to set.
        public void setDeckLevel(final int deckLevel) {
            this.deckLevel = deckLevel;
    Get method for the member "<code>shipId</code>".
    @return Returns the shipId.
        public int getShipId() {
            return this.shipId;
    Set method for the member "<code>shipId</code>".
    @param shipId The shipId to set.
        public void setShipId(final int shipId) {
            this.shipId = shipId;
    Get method for the member "<code>bedCount</code>".
    @return Returns the bedCount.
        public int getBedCount() {
            return this.bedCount;
    Set method for the member "<code>bedCount</code>".
    @param bedCount The bedCount to set.
        public void setBedCount(final int bedCount) {
            this.bedCount = bedCount;
    } // End of class Cabin
    [/code]
    After that I created the TravelAgentBean, a Stateless Session Bean, implementing
    a remote interface that allows construction and persisting of new Cabin objects:
    [code]
    package de.collogia.beans.session.stateless;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import de.collogia.beans.pojo.ship.Cabin;
    Class that implements the <code>TravelAgentRemote</code> interface
    and defines the business methods of the TravelAgent service.
    @author Henning Malzahn ([email protected])
    svn-revision:         $Rev:: 670                                           $:
    svn-lasted-edited-by: $Author:: henning                                    $:
    svn-last-changed:     $Date:: 2007-02-21 21:49:51 +0100 (Wed, 21 Feb 2007) $:
    @Stateless
    public class TravelAgentBean implements TravelAgentRemote {
        /** The <code>Log</code> object for this class. */
    //    private static final Log LOGGER;
        /** The <code>PersistenceManager</code> object. */
        @PersistenceContext(unitName = "titan_cruises_pu")
        EntityManager em;
    /---- Static initializer -/
    //    static {
    //        LOGGER = LogFactory.getLog(TravelAgentBean.class);
    //    } // End of static initializer block
    /---- Implementing remote interface methods -/
    {@inheritDoc}
        public void createCabin(final Cabin cabin) {
            this.em.persist(cabin);
        } // End of createCabin()
    } // End of class TravelAgentBean
    [/code]
    After that I created a Controller class containing a main method that looks up the remote
    interface of the TravelAgentBena like explained in document "Accessing Enterprise JavaBeans Using JNDI
    in SAP NetWeaver Application Server, Java ™ EE 5 Edition" written by Validimir Pavlov of SAP NetWeaver
    development team.
    Unfortunately I receive an Exception after invoking the createCabin(...) method.
    On the console of the NWDS I receive:
    [code]
    javax.ejb.EJBException: Exception in getMethodReady() for stateless bean sap.com/test2Earannotation|test2Ejb.jarannotation|TravelAgentBean;
    nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: Cannot perform injection over bean instance
    Caused by: java.lang.RuntimeException: The persistence unit is inconsistent:
    The entity >>de.collogia.beans.pojo.ship.Cabin<< is mapped to the table >>cabin<<, which does not exist.
    [/code]
    But if I look at the log file located in "C:\NWAS_JAVAEE5\JP1\JC00\j2ee\cluster\server0\log\defaultTrace.0.trc"
    I see the real reason is:
    [code]
    [EXCEPTION]
    #6#1064#42000#You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
    to use near '"cabin"' at line 1#collnx02.collogia.de:3306:null:practise_titan_cruises#select * from "cabin"#com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"cabin"' at line 1
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:3124)
         at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1149)
         at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1262)
         at com.sap.sql.jdbc.basic.BasicPreparedStatement.executeQuery(BasicPreparedStatement.java:99)
         at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java:307)
         at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java:264)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:274)
    [/code]
    My goodness - what a long post - sorry for this - I hope I provided all information
    necessary to deal with the issue.
    Am I thinking in the right direction to blame attribute [code]<sql-engine>native_sql</sql-engine>[/code]
    of file data-sources.xml for the beaviour? Are there any other argument options than native_sql?
    Thanks in Advance!
    Henning Malzahn

    Hi Henning,
    > Despite the fact it's working now I have to do some
    > changes to my code currently
    > developed using JBoss/ Hibernate combination.
    > Hibernate allows you to have the
    > default no-arg constructor with private visibility -
    > any special reason for the fact that
    > only protected is allowed on NetWeaver?
    Here we strictly implemented the checks according to the requirements of the JPA specification. Technically, we could do with private constructors as well. But the JPA specifications requires the constructor to be protected to allow a JPA implementation to subclass entities if needed.
    > The entities in the project are final classes
    > so declaring a ctor protected doesn't really make
    > sense...
    For the same reason, your entities should not be final. Are we missing a check here ?
    > Also the persistence.xml parameter
    >
    hibernate.hbm2ddl.auto
    with the value of
    > create-drop is very useful while
    > developing the app - everytime you deploy the project
    > you get a fresh database.
    > Is there a comparable option for NetWeaver?
    No, unfortunately, there is no comparable option in SAP JPA (yet). We understand that there is a need for forward mapping. We would have liked to delegate this task to the JPA design time (i.e. Dali). However, we had to discover that Dali does not perform this task properly and we can't recommend using it any more.
    Consequently, there is no automatic schema generation in SAP JPA 1.0.
    >
    > Another thing is the extra TMP_SEQUENCE table which
    > isn't necessary using JBoss and
    > Hibernate - what's the reason for that?
    With Hibernate Entity Manager, the id generation strategy in use with GenerationType.AUTO depends on the database dialect. This means that depending on the database dialect, IDENTITY columns, SEQUENCES or generator tables (TableHiLo) are required. As Hibernate has the before mentioned schema generation property this fact can be hidden to the user.
    In SAP JPA, we are always using a table generator if GenerationType.AUTO is used. This allows for better portability across databases. It requires the table TMP_SEQUENCE. As we unfortunately do not have a schema generation capability, the user must create this table.
    Best regards,
    Adrian

  • JSP with MYSQL 4.0

    May i know is JSP works well with MYSQL 4.0 database?

    Yaah..it works perfectly OK....just download the required driver my mysql site only & ur ready to develop applications is JSP using mysql.

  • Create LOVS in jsp with ViewObjects

    Hello,
    I want to create a jsp-page containing two LOV's (html-<selects>). The first LOV is based on a VO named COUNTRIES. The second LOV is based on a VO named COMPANIES. There's a View Link between the two VO's.
    I am using the BC4j-Tags from the Component Palette. What I have to do to synchronize the both LOV's. For example, if I select a country, only specific companies have to appear in the COMPANY LOV.
    Thanks for your help.
    Peter

    Within jsp pages it is not possible to have the comboboxes dynamically updated without intervention to either refresh the page with the new data or use java script.
    I had a similar problem which i resolved with java script :
    Interactive combo boxes on jsp
    Have a look at this thread for more info.

  • JSP with MySQL connection in Tomcat6.0.20

    Hi i'm using MySQL5.1, Tomcat6.0.20 in my project, There i'm not able to connect to the database. it's giving the error.
    My program is :
    <%@ page language="java" import="java.sql.*" %>
    <%
         String driver = "org.gjt.mm.mysql.Driver";
         Class.forName(driver).newInstance();
         try{
              String url="jdbc:mysql://localhost/books?user=root@localhost&password=india123";
              Connection con=DriverManager.getConnection(url);
              Statement stmt=con.createStatement();
         catch(Exception e){
              System.out.println(e.getMessage());
         if(request.getParameter("action") != null){
              String bookname=request.getParameter("book_name");
              String author=request.getParameter("author");
              stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
              ResultSet rst=stmt.executeQuery("select * from books_lib");
              %>
              <html>
              <body>
              <center>
                   <h2>Books List</h2>
                   <table border="1" cellspacing="0" cellpadding="0">
                   <tr>
                        <td><b>S.No</b></td>
                        <td><b>Book Name</b></td>
                        <td><b>Author</.b></td>
                   </tr>
                        <%
                        int no=1;
                        while(rst.next()){
                        %>
                        <tr>
                        <td><%=no%></td>
                        <td><%=rst.getString("book_name")%></td>
                        <td> <%=rst.getString("author")%> </td>
                        </tr>
                        <%
                        no++;
         rst.close();
         stmt.close();
         con.close();
    %>
                   </table>
                   </center>
              </body>
         </html>
    <%}else{%>
         <html>
         <head>
              <title>Book Entry FormDocument</title>
              <script language="javascript">
              function validate(objForm){
                   if(objForm.bookname.value.length==0){
                   alert("Please enter Book Name!");
                   objForm.bookname.focus();
                   return false;
                   if(objForm.author.value.length==0){
                   alert("Please enter Author name!");
                   objForm.author.focus();
                   return false;
                   return true;
                   </script>
              </head>
              <body>
                   <center>
    <form action="BookEntryForm.jsp" method="post" name="entry" onSubmit="return validate(this)">
         <input type="hidden" value="list" name="action">
         <table border="1" cellpadding="0" cellspacing="0">
         <tr>
              <td>
                   <table>
                        <tr>
                        <td colspan="2" align="center">
    <h2>Book Entry Form</h2></td>
                        </tr>
                        <tr>
                        <td colspan="2"> </td>
                        </tr>
                        <tr>
                        <td>Book Name:</td>
                        <td><input name="bookname" type="text" size="50"></td>
                        </tr>
                        <tr>
                        <td>Author:</td><td><input name="author" type="text" size="50"></td>
                        </tr>
                        <tr>
                             <td colspan="2" align="center">
    <input type="submit" value="Submit"></td>
                             </tr>
                        </table>
                   </td>
              </tr>
         </table>     
    </form>
                   </center>
              </body>
         </html>
    <%}%>
    The error page is:
    HTTP Status 500
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 19 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    16:      if(request.getParameter("action") != null){
    17:           String bookname=request.getParameter("book_name");
    18:           String author=request.getParameter("author");
    19:           stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
    20:           ResultSet rst=stmt.executeQuery("select * from books_lib");
    21:           %>
    22:           <html>
    An error occurred at line: 20 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    17:           String bookname=request.getParameter("book_name");
    18:           String author=request.getParameter("author");
    19:           stmt.executeUpdate("insert into books_lib(book_name,author) values('"+bookname+"','"+author+"')");
    20:           ResultSet rst=stmt.executeQuery("select * from books_lib");
    21:           %>
    22:           <html>
    23:           <body>
    An error occurred at line: 45 in the jsp file: /singleupload/BookEntryForm.jsp
    stmt cannot be resolved
    42:                     no++;
    43:      }
    44:      rst.close();
    45:      stmt.close();
    46:      con.close();
    47: %>
    48:                </table>
    An error occurred at line: 46 in the jsp file: /singleupload/BookEntryForm.jsp
    con cannot be resolved
    43:      }
    44:      rst.close();
    45:      stmt.close();
    46:      con.close();
    47: %>
    48:                </table>
    49:                </center>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    Please help me

    ?An error occurred at line: 20 in the jsp file: /singleupload/BookEntryForm.jsp stmt cannot be resolved
    That means it can't see any variable declared called "stmt"
    There isn't one at this point.
    The stmt variable you have declared up above, is nested in curly braces - within your try/catch statement. As such it only has scope within those curly braces. If you want to use stmt outside of the try block, you need to declare stmt outside of it.
    And yes, I echo Balusc's comments about scriptlet code in a jsp page.
    A better solution would be to write a java class with a method that does the database query, and returns a List of objects.
    Your JSP can then take that list of objects and display them on the page.
    Its a bit more work, but makes the code much easier to write/maintain/test because you separate out the "data" and "view" layers.

  • JSP with mysql database

    *********************This is my HTML form for Media search*****************
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>search media form</title>
    </head>
    <body>
    <form name="search" action="med_search.jsp"> <big
    style="font-weight: bold; color: rgb(0, 102, 0);">Media
    : Search<br>
    </big>
    <hr
    style="height: 1px; width: 50%; margin-left: 0px; margin-right: auto;"><label>Media
    :   equals :</label><big
    style="font-weight: bold; color: rgb(0, 102, 0);">  
    <select size="1" name="msearch_name">
    <option>-All-</option>
    <option>100% Home Girls</option>
    <option>1800mumanddad</option>
    <option>2D Max</option>
    <option>Access all areas</option>
    <option>Adelaide Advertiser</option>
    <option>Adelaide Messenger</option>
    <option>Adelaide Sunday Mail TV guide</option>
    <option>All Media</option>
    <option>Ari Reserved</option>
    <option>Austar</option>
    <option>Blockbuster</option>
    <option>Brisbane Courier Mail</option>
    <option>Brisbane Quest</option>
    <option>Brisbane Sunday Mail- TV guide</option>
    <option>Cleo</option>
    <option>Community</option>
    <option>Cosmo</option>
    <option>Day Time TV</option>
    <option>Dolly</option>
    <option>Edge</option>
    <option>Empire</option>
    <option>EMS</option>
    <option>Explode</option>
    <option>Facing Sanity</option>
    <option>Fairfax</option>
    <option>FHM</option>
    <option>Foxtel</option>
    <option>Funkysexycool</option>
    <option>Gametel newsletter</option>
    <option>Gametel Sim Pack</option>
    <option>Gametel UI 1st Version</option>
    <option>Gametel UI 2nd Version</option>
    <option>Gametel Website</option>
    <option>Geelong Advertiser-TV guide</option>
    <option>Girlfriend</option>
    <option>Good Medicine</option>
    <option>Herald Sun</option>
    <option>Home Girls</option>
    <option>Insight</option>
    <option>MailBlast</option>
    <option>Maximum Performance</option>
    <option>Melboume Leader</option>
    <option>Mobile</option>
    <option>Mobile Pet-Ari</option>
    <option>Money Saver</option>
    <option>Motor Show Mag</option>
    <option>Mr.Wisdoms Whopper</option>
    <option>MTV</option>
    <option>Music Australia</option>
    <option>New Chat</option>
    <option>New Idea</option>
    <option>NW Magazine</option>
    <option>One Love</option>
    <option>Optus</option>
    <option>Penthouse</option>
    <option>People</option>
    <option>Picture</option>
    <option>Picture Premium Edition</option>
    <option>Picture Premium Special</option>
    <option>Platinum Girls</option>
    <option>Phychic Business Cards</option>
    <option>Phychic Calender</option>
    <option>Phychic CD Cover</option>
    <option>Ralph</option>
    <option>Sain Magazine</option>
    <option>Sanity Chart</option>
    <option>Series 40 gametel subscriber</option>
    <option>Series 60 gametel community</option>
    <option>Series 60 gametel non-subscriber</option>
    <option>Series40 non-subscriber</option>
    <option>Smash Hits</option>
    <option>SMS Chat</option>
    <option>Soap World</option>
    <option>SPAM</option>
    <option>STM-WA</option>
    <option>Stupid People Line</option>
    <option>Sunday Herald Sun TV guide</option>
    <option>Sunday Telegraph TV guide</option>
    <option>Sunday Times TV guide</option>
    <option>Sydney Cumberland</option>
    <option>Sydney Daily telegraph</option>
    <option>Take 5</option>
    <option>Tasmania TV guide</option>
    <option>That's Life</option>
    <option>Total Gamer</option>
    <option>TV 10</option>
    <option>TV 7</option>
    <option>TV 9</option>
    <option>TV Hits</option>
    <option>TV Soap</option>
    <option>TV Week</option>
    <option>UNASSIGNED</option>
    <option>Urban Hits</option>
    <option>VH1</option>
    <option>Video Ezy</option>
    <option>Vogue Girl</option>
    <option>WAP</option>
    <option>Web Competitions</option>
    <option>Website</option>
    <option>West Magazine</option>
    <option>Western Australian</option>
    <option>What DVD</option>
    <option>What's Hot on Video</option>
    <option>Witchcraft</option>
    <option>Women's Day</option>
    <option>xxx</option>
    </select>
    <br>
    <span style="font-weight: bold;"><span
    style="color: rgb(0, 102, 0);"><span
    style="font-weight: bold;"><span
    style="font-weight: bold;"></span></span></span></span></big><big
    style="font-weight: bold; color: rgb(0, 102, 0);">  
          </big><big
    style="color: rgb(0, 102, 0);"><small><label
    style="color: rgb(0, 0, 0);">or
    is like :</label></small></big><big
    style="font-weight: bold; color: rgb(0, 102, 0);">  
    <textarea cols="20" rows="1" name="msearch_like"></textarea><br>
         </big><label
    style="color: rgb(0, 0, 0);">Media Type
    :</label><big style="font-weight: bold; color: rgb(0, 102, 0);">
    <select size="1" name="msearch_type">
    <option>-All-</option>
    <option>magazine</option>
    <option>newspaper</option>
    <option>other</option>
    <option>tv</option>
    <option>tv guide</option>
    </select>
    <br>
    <br>
    </big> <input name="med_search" value="Search"
    type="submit">  <input name="med_reset"
    value="Reset" type="reset"></form>
    <br>
    <br>
    </body>
    </html>
    //After clicking search button it will go to this jsp and gets the searched records.
    ***********************************med_search.jsp***********************
    <html>
    <body>
    <h1>Search Media</h1>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page import="java.sql.*" %>
    <% Connection con=null;%>
    <% PreparedStatement pstmt=null;%>
    <%
    try
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://silverbullet:3306/elmophish", "sirisha", "gametel123");
    out.println("<table border=0>");
    if(request.getParameter("msearch_name").equals("-All-")&request.getParameter("msearch_type").equals("-All-"))
    %>
    <jsp:forward page="med_search.html"/>
    <%
    else if(!(request.getParameter("msearch_name").equals("-All-"))&!(request.getParameter("msearch_type").equals("-All-")))
    pstmt=con.prepareStatement("select media.media_name,media.media_code,media_types.media_type,media_genders.media_gender,media.target_age,publishers.publisher,media.is_bookable,media_id from media,media_types,media_genders,publishers where media_name in (select media_name from media where media_type_id in (select media_type_id from media_types where media_type=" + "'" + request.getParameter("msearch_type") + "'" +") and media.media_name =" + "'" + request.getParameter("msearch_name") +"'" + ")and media.media_type_id=media_types.media_type_id and media.target_gender_id=media_genders.media_gender_id and media.publisher_id=publishers.publisher_id");
    out.println("<th></th><th><b>Name</b>&nbsp</th><th><b>Code</b>&nbsp</th><th><b>Type</b>&nbsp</th><th><b>Gender</b>&nbsp</th><th><b>Age</b>&nbsp</th><th><b>Publisher</b>&nbsp</th><th><b>Active</b>&nbsp</th>");
    else if(!(request.getParameter("msearch_name").equals("-All-"))&&(request.getParameter("msearch_type").equals("-All-")))
    pstmt=con.prepareStatement("select media_name,media_code,media_type,media_gender,target_age,publisher,is_bookable,media_id from media me inner join media_types mt on me.media_type_id = mt.media_type_id inner join media_genders mg on mg.media_gender_id = me.target_gender_id inner join publishers pub on pub.publisher_id = me.publisher_id where media_name="+"'"+request.getParameter("msearch_name")+"'"+"") ;
    out.println("<th></th><th><b>Name</b>&nbsp</th><th><b>Code</b>&nbsp</th><th><b>Type</b>&nbsp</th><th><b>Gender</b>&nbsp</th><th><b>Age</b>&nbsp</th><th><b>Publisher</b>&nbsp</th><th><b>Active</b>&nbsp</th>");
    else if(request.getParameter("msearch_name").equals("-All-")&!(request.getParameter("msearch_type").equals("-All-")))
    pstmt=con.prepareStatement("select media_name,media_code,media_type,media_gender,target_age,publisher,is_bookable,media_id from media me inner join media_types mt on me.media_type_id = mt.media_type_id inner join media_genders mg on mg.media_gender_id = me.target_gender_id left join publishers pub on pub.publisher_id = me.publisher_id where media_type=" + "'"+request.getParameter("msearch_type")+"'"+"");
    out.println("<th></th><th><b>Name</b>&nbsp</th><th><b>Code</b>&nbsp</th><th><b>Type</b>&nbsp</th><th><b>Gender</b>&nbsp</th><th><b>Age</b>&nbsp</th><th><b>Publisher</b>&nbsp</th><th><b>Active</b>&nbsp</th>");
    ResultSet rst=pstmt.executeQuery();
    ResultSetMetaData rsmd=rst.getMetaData();
    int n=rsmd.getColumnCount();
    while(rst.next())
    out.println("<tr>");
    %>
    <td><form action="test.jsp" method="post"> <a href="t.jsp?media_id=<% out.print(rst.getString(8)); %>">Edit</a></form></td>
    <%
    out.print("<td>"+rst.getString(1)+"</td>");
    out.print("<td>"+rst.getString(2)+"</td>");
    out.print("<td>"+rst.getString(3)+"</td>");
    out.print("<td>"+rst.getString(4)+"</td>");
    out.print("<td>"+rst.getString(5)+"</td>");
    out.print("<td>"+rst.getString(6)+"</td>");
    out.print("<td>"+rst.getString(7)+"</td>");
    out.print("</tr>");
    }catch(Exception e)
    out.println(e);
    finally
    con.close();
    %>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    </body>
    </html>
    //In this search output we have edit button for each row.After we click search it will enter into another form where we can edit the record.
    //In this jsp,i have designed the form for editing and displayed the current record values as initial values and after edit it must save and update the DB.But before I click save changes,its updating the DB with all zeros.
    ******************edit_search.jsp**************************************
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <h1>Edit Search</h1>
    </head>
    <body>
    <%@ page import="java.sql.*" %>
    <% Connection con=null;%>
    <% String str1,str2,str3,str4,str5,str6;%>
    <%
    try
    int mgid=0;
    int tage=0;
    int pid=0;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://silverbullet:3306/elmophish", "sirisha", "gametel123");
    PreparedStatement pstmt=con.prepareStatement("SELECT media_name,media_code,media_type,media_gender,target_age,publisher,is_bookable FROM media m INNER JOIN media_types met ON m.media_type_id = met.media_type_id INNER JOIN media_genders meg ON m.target_gender_id = meg.media_gender_id LEFT JOIN publishers pubs ON m.publisher_id = pubs.publisher_id where media_id=" + "'"+request.getParameter("media_id")+"'");
    ResultSet rs=pstmt.executeQuery();
    ResultSetMetaData rsmd=rs.getMetaData();
    int n=rsmd.getColumnCount();
    while(rs.next())
    %>
    <form method="post" action="">
    <label>Name</label> <%=rs.getString("media_name")%><br>
    <label>Code</label> <textarea cols="20" rows="1"name="med_code"><%=rs.getString("media_code")%></textarea><br>
    <label>Type</label> <%=rs.getString("media_type")%><br>
    <label>Target Gender</label>&nbsp
    <% PreparedStatement pstmt2=con.prepareStatement("SELECT media_gender FROM media_genders");
    ResultSet rst1=pstmt2.executeQuery();
    ResultSetMetaData rstmd2=rst1.getMetaData();
    int cnt1=rstmd2.getColumnCount();
    %>
    <select name="tar_gen">
    <%
    while(rst1.next())
    %>
    <option><%=rst1.getString("media_gender")+"<br>"%></option>
    <%
    %>
    </select><br>
    <label>Target Age</label> <textarea cols="20" rows="1" name="med_age"><%=rs.getString("target_age")%></textarea><br>
    <label>Publisher</label> 
    <%
    PreparedStatement pstmt1=con.prepareStatement("SELECT publisher FROM publishers");
    rst1=pstmt1.executeQuery();
    ResultSetMetaData rstmd1=rst1.getMetaData();
    int cnt2=rstmd1.getColumnCount();
    %>
    <select name="pub">
    <%
    while(rst1.next())
    %>
    <option><%=rst1.getString("publisher")+"<br>"%></option>
    <%
    %>
    </select><br>
    <label>Bookable</label> 
    <input type="checkbox">
    <%
    if (rs.getString("is_bookable").equals("1"))
    %>
    <checkbox maxlength="20" <checked></checkbox>
    <%
    else
    %>
    <checkbox maxlength="20" <unchecked></checkbox>
    <%
    %>
    <%
    str1=request.getParameter("med_code");
    PreparedStatement pst2=con.prepareStatement("select media_gender_id from media_genders where media_gender = "+ "'" + request.getParameter("med_gen") +"'");
    ResultSet rst2=pst2.executeQuery();
    while(rst2.next())
    mgid=rst2.getInt(1);
    rst2.close();
    str2=request.getParameter("med_gen");
    try
    tage=Integer.parseInt("'"+request.getParameter("med_age")+"'");
    catch(NumberFormatException e){}
    PreparedStatement pst3=con.prepareStatement("select publisher_id from publishers where publisher = "+ "'" + request.getParameter("pub")+"'");
    ResultSet rst3=pst3.executeQuery();
    ResultSetMetaData rsmd3=rst3.getMetaData();
    int nnn=rsmd3.getColumnCount();
    while(rst3.next())
    pid=rst3.getInt(1);
    rst3.close();
    //str4=request.getParameter("pub");
    try
    if(request.getParameter("bookable").equals("true"))
    str5="1";
    }catch(Exception e)
    str5="0";
    //str5=request.getParameter("bookable"");
    %><input name="med_edit" value="Save Changes" type="submit"><br></form>
    <%
    //out.println("<h2>2"+str1+"</h2>");
    PreparedStatement pstmt3=con.prepareStatement("UPDATE media set media_code="+str1+",target_gender_id="+mgid+",target_age="+tage+",publisher_id="+pid+" WHERE media_id="+"'"+request.getParameter("media_id")+"'");
    pstmt3.executeUpdate();
    //ResultSet res=.updateRow();
    //out.println("<h2>3"+str1+"</h2>");
    }catch(Exception e)
    out.println(e);
    finally
    con.close();
    %>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    </body>
    </html>
    //This is another jsp which i replaced for edit_search.jsp.Functionality is same.And also giving the same result.But this is some what clear than edit_search.jsp.
    ****************************test.jsp******************************
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <%@ page import="java.sql.*" %>
    <% Connection con=null;%>
    <% String str1=null;
    String str2=null;
    String str3=null;
    String mgid=null;
    String tage=null;
    String pid=null;
    %>
    <%
    try
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://silverbullet:3306/elmophish", "sirisha", "gametel123");
    PreparedStatement pstmt=con.prepareStatement("SELECT media_name,media_code,media_type,media_gender,target_age,publisher,is_bookable FROM media m INNER JOIN media_types met ON m.media_type_id = met.media_type_id INNER JOIN media_genders meg ON m.target_gender_id = meg.media_gender_id LEFT JOIN publishers pubs ON m.publisher_id = pubs.publisher_id where media_id=" + "'"+request.getParameter("media_id")+"'");
    ResultSet rs=pstmt.executeQuery();
    while(rs.next()){
    %>
    <form method="post" action="">
    <label>Name</label> <%=rs.getString("media_name")%><br>
    <label>Code</label> <textarea cols="20" rows="1"name="med_code"><%=rs.getString("media_code")%></textarea><br>
    <label>Type</label> <%=rs.getString("media_type")%><br>
    <label>Target Gender</label>&nbsp
    <% PreparedStatement pstmt1=con.prepareStatement("SELECT media_gender FROM media_genders");
    ResultSet rst1=pstmt1.executeQuery();
    %>
    <select name="tar_gen">
    <%
    while(rst1.next())
    %>
    <option><%=rst1.getString("media_gender")%></option>
    <%
    %>
    </select><br>
    <label>Target Age</label> <textarea cols="20" rows="1" name="med_age"><%=rs.getString("target_age")%></textarea><br>
    <label>Publisher</label> 
    <%
    PreparedStatement pstmt2=con.prepareStatement("SELECT publisher FROM publishers");
    ResultSet rst2=pstmt2.executeQuery();
    %>
    <select name="pub">
    <%
    while(rst2.next())
    %>
    <option><%=rst2.getString("publisher")%></option>
    <%
    %>
    </select><br>
    <label>Bookable</label> 
    <input type="checkbox">
    <%
    if (rs.getString("is_bookable").equals("1"))
    %>
    <checkbox maxlength="20" <checked></checkbox>
    <%
    else
    %>
    <checkbox maxlength="20" <unchecked></checkbox>
    <%
    str1=request.getParameter("med_code");
    PreparedStatement pstmt3=con.prepareStatement("select media_gender_id from media_genders where media_gender = "+ "'" + request.getParameter("med_gen") +"'");
    ResultSet rst3=pstmt3.executeQuery();
    while(rst3.next()){
    mgid=rst3.getString("media_gender_id");
    rst3.close();
    try
    tage=request.getParameter("med_age");
    catch(NumberFormatException e){}
    PreparedStatement pstmt4=con.prepareStatement("select publisher_id from publishers where publisher = "+ "'" + request.getParameter("pub")+"'");
    ResultSet rst4=pstmt4.executeQuery();
    while(rst4.next()){
    pid=rst4.getString("publisher_id");
    rst4.close();
    try
    if(request.getParameter("bookable").equals("true"))
    str3="1";
    catch(Exception e)
    str3="0";
    %>
    <input type="submit" value="Save Changes"><br></form>
    <%
    PreparedStatement pstmt5=con.prepareStatement("UPDATE media set media_code="+str1+",target_gender_id="+mgid+",target_age="+tage+",publisher_id="+pid+",is_Bookable="+str3+" WHERE media_id="+"'"+request.getParameter("media_id")+"'");
    pstmt5.executeUpdate();
    out.println("123"+"media_code"+str1+" gender"+mgid+"....age.."+tage+"publisher_id="+pid+" is_Bookable="+str3);
    catch(Exception e)
    out.println("ttttttttttt");
    out.println(e);
    finally
    con.close();
    %>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    </body>
    </html>
    *********************************************************************

    I want to know or How to connect Mysql
    with JSP or JSF any other software isavailable?
    please help me.....First you need to find 25 m of a CatV cable and...The DB files need to be located on the ninth device of a SCSI Daisy Chain with the total SCSI cable length being over 150 m (and the devices (and cables) need to be mix of Differential and Non-Differential).
    Edit: And forget the terminator, who needs it?

  • How to connect JSP with MySql Database?

    HI All...
    I want to know or How to connect Mysql with JSP or JSF any other software is available? please help me.....

    I want to know or How to connect Mysql
    with JSP or JSF any other software isavailable?
    please help me.....First you need to find 25 m of a CatV cable and...The DB files need to be located on the ninth device of a SCSI Daisy Chain with the total SCSI cable length being over 150 m (and the devices (and cables) need to be mix of Differential and Non-Differential).
    Edit: And forget the terminator, who needs it?

  • JSP with MYSQL on linux and windows2k

    I am using a linux box as a web server with tomcat and mysql. I aslo have a mirror on a Win2k machine running the same environment.
    I have a jsp file that uses a bean to update the database and it works on the win2k environment but not linux.
    In windows I see error messages in the tomcat console, how do I see these message on linux?
    Thank you,
    Paul.

    Did you check ALL of the files?
    There are files named "localhost_log.TODAYSDATE.txt", there are files named "catalina_log.TODAYSDATE.txt", and there's a file called "catalina.out".
    "catalina.out" appears to contain information very similar to the DOS output screen on the Windows platform.
    If those files don't have what you're looking for, then you'll have to get help from someone with more expertise than myself!

  • JSP with MYSQL.

    Dear Friends
    I have a unique problem in java, when i try to connect to mysql db.
    It shows an error message:
    Unable to load driver. Getting Connection ... SQLException: No suitable driverI am using mysql MySQL 4.1.9 and tomcat 5.5 version.
    though i have loaded the driver in lib directory, it still displays the same error
    messgae. Here is the jsp file which i use to connect to my database.
    http://localhost:8080/mysqljdbc.jsp
    <%@ page import="java.net.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.sql.*" %>
    <%
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         catch (Exception E) {
         out.println("Unable to load driver.");
         E.printStackTrace();
         try{
              out.println("Getting Connection ...");
              Connection C = DriverManager.getConnection("jdbc:mysql://localhost:3306/vinoth");
              out.println("<br>Connected:  " + !C.isClosed() + "<br>\n");
              out.println("Catalog:  " + C.getCatalog() + "<br>\n");
                   Statement S = C.createStatement();
                   ResultSet rs = S.executeQuery("SELECT * FROM foo");
                   ResultSetMetaData rsStruc = rs.getMetaData();
                   out.println("Table:  " + rsStruc.getTableName(1) + "<br>");
                   out.println("<table bgcolor=c8c8c8 cellpadding=5 cellspacing=1>");
                   out.println("<tr bgcolor=000000>");
                   int colCount = rsStruc.getColumnCount();
                   String colName = "";
                   for(int i=1;i <= colCount; i++){
                   colName = rsStruc.getColumnName(i) ;
                   out.println("<td><B><font color=white>" + colName + "</font></b></td>\n");
                   out.println("</tr>");
                   while (rs.next()) {
                   out.println("<tr bgcolor=ffffff>");
                   for(int i=1;i <= colCount; i++){
                   colName = rsStruc.getColumnName(i) ;
                   String fld = rs.getString(colName);
                        out.println("<td>" + fld + "</td>");
                   out.println("</tr>");
                   out.println("</table>");
                   rs.close();
                   C.close();
         catch (Exception E) {
          out.println("SQLException: " + E.getMessage());
    %>Now is there anything i have to configure apart from this.
    Thanx in advance.

    First things first...i definitely recommend you take out the db stuff out of the jsp page. Place the logic in a DAO and if you have to reference the dao in the jsp. Although in a practice you should have a service layer which does the db stuff. Use a servlet to call the service layer and pass the results of the service layer to the jsp.
    Writing java code like that in the jsp is just bad programming. There are loads of web frameworks that enable you to develop scalable web applications.
    I realise that this does not help you but it is a good idea to get the design correct before embarking on the development.

  • PleaseHelp on jsp and Mysql connectivity and a lot of exception errors

    Hi,
    I am Trying to connect a JSP page with Mysql database. I am having a lot of probelms. After having a lot of problems in connecting the JSp with Mysql. Intilally it was giving me the exception error that " NO appropriate driver was found. After modifying the URl it was fine. Now It is giving the Following errors.
    servlet.ServletException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream
    In a window before loading the Explorer page it is giving the following error that The port 8081 is already in use and i should expand to other ports. Noraml JSP Files which used to work before are also not working .
    Internal Tomcat JWSDP is alos not working. If i try to start the server it says that port 8081 is already in USe . A java.net.connection exception is also occuring. The normal JSP files are also not working. What is Happening. I am also giving the code i have writted. PLease tellme why so many exception errors are occuring.
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8081/mis_project", "root", " ");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select study_semester FROM Semester");
    while(rs.next()) {
    %>
    <option value="<%= rs.getString("Study_Semester") %>">
    </option>
    <% }
    if(rs!=null) rs.close();
    if(stmt!=null) stmt.close();
    if(con!=null) con.close();
    I am trying to connect to Mysql and automatocally populate a field in a Form in later JSp pages i intend to record the data entered in these fields into other tables.

    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/myDB?user=username&password=mypass");
    Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
    String cat = "";
              try{
              cat = request.getParameter("category");
              }catch(NullPointerException npe){}
              ResultSet rs = stmt.executeQuery("SELECT id,fullname FROM users WHERE category LIKE '%motor%' AND subcategory like '%"+cat+"%'");
         %>
    This piece gets a category parameter from a form post and uses it to search for a specific category in a database table. I think maybe u need to download JConnector from mysql site and unzip it to the classes folder of your WEB-INF in Tomcat server...... i hope this helps a bit

  • Connectivity with MySQL in Windows

    How can I connect JSP with MySQL in Windows?
              I Tried out the following code but It did not work
              Class.forName("org.gjt.mm.mysql.Driver");
              Connection cn = DriverManager.getConnection("jdbc:mysql:///test");
              

    I think you missed the IP address for your MySQL server machine.
              If it's on the same computer, try this:
              jdbc:mysql://localhost/test
              "John Jacob" <[email protected]> wrote in message
              news:[email protected]..
              > How can I connect JSP with MySQL in Windows?
              > I Tried out the following code but It did not work
              >
              > Class.forName("org.gjt.mm.mysql.Driver");
              > Connection cn = DriverManager.getConnection("jdbc:mysql:///test");
              

  • Weird problem with mysql query and data table buttons !!!!

    Hi,
    I'm using jsc 2 update 1 on windows and mysql 4.1 . I have a page with a data table. One column of the data table contains "Details" buttons.
    Source query for the table is :
    SELECT tbl_tesserati.idtbl_tesserati idTesserato,
    tbl_tesserati.num_tessera,
    tbl_tesserati.nome,
    tbl_societa.codice_meccanografico
    FROM tbl_tesserati
    INNER JOIN tbl_rel_tesserato_discipline_societa ON tbl_tesserati.idtbl_tesserati = tbl_rel_tesserato_discipline_societa.id_tesserato
    INNER JOIN tbl_cariche ON      tbl_rel_tesserato_discipline_societa.id_carica = tbl_cariche.idtbl_cariche
    INNER JOIN tbl_qualifiche ON      tbl_rel_tesserato_discipline_societa.id_qualifica = tbl_qualifiche.idtbl_qualifiche
    INNER JOIN tbl_discipline ON      tbl_rel_tesserato_discipline_societa.id_disciplina = tbl_discipline.idtbl_discipline
    INNER JOIN tbl_societa ON      tbl_rel_tesserato_discipline_societa.id_societa = tbl_societa.idtbl_societa
    LEFT JOIN tbl_province ON tbl_societa.provincia_sede_sociale = tbl_province.idtbl_province
    LEFT JOIN tbl_comuni ON tbl_societa.comune_sede_sociale = tbl_comuni.idtbl_comuni
    LEFT JOIN tbl_rel_tesserato_discipline_praticate ON tbl_rel_tesserato_discipline_praticate.tessera_id=
    tbl_rel_tesserato_discipline_societa.idtbl_rel_tesserato_discipline
    LEFT JOIN tbl_discipline_praticate ON tbl_discipline_praticate.idtbl_disciplina_praticate=tbl_rel_tesserato_discipline_praticate.disciplina_praticata_id
    WHERE
    tbl_tesserati.cognome LIKE ?
    AND tbl_tesserati.nome LIKE ?
    AND tbl_rel_tesserato_discipline_societa.id_societa LIKE ?
    AND tbl_tesserati.idtbl_tesserati LIKE ?
    AND tbl_cariche.idtbl_cariche LIKE ?
    AND tbl_qualifiche.idtbl_qualifiche LIKE ?
    AND tbl_tesserati.data_nascita >= ?
    AND tbl_tesserati.data_nascita<= ?
    AND tbl_discipline.idtbl_discipline LIKE ?
    AND codice_affiliazione LIKE ?
    AND tbl_societa.denominazione LIKE ?
    AND YEAR(tbl_rel_tesserato_discipline_societa.data_scadenza) LIKE ?
    AND (tbl_province.nome LIKE ? OR tbl_province.nome IS NULL)
    AND ( tbl_comuni.nome LIKE ? OR tbl_comuni.nome IS NULL)
    The tbl_tesserati.data_nascita is a mysql date field.
    The click event handler code for the "Details" Button is:
    public String btnModificaTesserato_action() {
            try{
                TableRowDataProvider rowData= (TableRowDataProvider)getBean("currentRowTesserati");
                getRequestBean1().setId_tesserato((Long)rowData.getValue("idTesserato"));          
            } catch(Exception ex) {
                log("errore nella query",ex);
            return "dettaglioTesseratoSocieta";
        }When i run the project and open the page the table is correctly rendered and populated with some rows. But when i click on details button nothing happens, the page is simply reloaded.
    If i set a breakpoint in the code line   TableRowDataProvider rowData= (TableRowDataProvider)getBean("currentRowTesserati");the debbuger does not stop the code execution ! As if the button was never clicked!
    I tried to modify the source query to :
    SELECT tbl_tesserati.idtbl_tesserati idTesserato,
    tbl_tesserati.num_tessera,
    tbl_tesserati.nome,
    tbl_societa.codice_meccanografico
    FROM tbl_tesserati
    INNER JOIN tbl_rel_tesserato_discipline_societa ON tbl_tesserati.idtbl_tesserati = tbl_rel_tesserato_discipline_societa.id_tesserato
    INNER JOIN tbl_cariche ON      tbl_rel_tesserato_discipline_societa.id_carica = tbl_cariche.idtbl_cariche
    INNER JOIN tbl_qualifiche ON      tbl_rel_tesserato_discipline_societa.id_qualifica = tbl_qualifiche.idtbl_qualifiche
    INNER JOIN tbl_discipline ON      tbl_rel_tesserato_discipline_societa.id_disciplina = tbl_discipline.idtbl_discipline
    INNER JOIN tbl_societa ON      tbl_rel_tesserato_discipline_societa.id_societa = tbl_societa.idtbl_societa
    LEFT JOIN tbl_province ON tbl_societa.provincia_sede_sociale = tbl_province.idtbl_province
    LEFT JOIN tbl_comuni ON tbl_societa.comune_sede_sociale = tbl_comuni.idtbl_comuni
    LEFT JOIN tbl_rel_tesserato_discipline_praticate ON tbl_rel_tesserato_discipline_praticate.tessera_id=
    tbl_rel_tesserato_discipline_societa.idtbl_rel_tesserato_discipline
    LEFT JOIN tbl_discipline_praticate ON tbl_discipline_praticate.idtbl_disciplina_praticate=tbl_rel_tesserato_discipline_praticate.disciplina_praticata_id
    WHERE
    tbl_tesserati.cognome LIKE ?
    AND tbl_tesserati.nome LIKE ?
    AND tbl_rel_tesserato_discipline_societa.id_societa LIKE ?
    AND tbl_tesserati.idtbl_tesserati LIKE ?
    AND tbl_cariche.idtbl_cariche LIKE ?
    AND tbl_qualifiche.idtbl_qualifiche LIKE ?
    AND tbl_tesserati.data_nascita >= ?
    OR tbl_tesserati.data_nascita<= ?
    AND tbl_discipline.idtbl_discipline LIKE ?
    AND codice_affiliazione LIKE ?
    AND tbl_societa.denominazione LIKE ?
    AND YEAR(tbl_rel_tesserato_discipline_societa.data_scadenza) LIKE ?
    AND (tbl_province.nome LIKE ? OR tbl_province.nome IS NULL)
    AND ( tbl_comuni.nome LIKE ? OR tbl_comuni.nome IS NULL)
    Using this query everything works well !! The click handler works and the debugger too !!
    I changed only the AND in OR !!!
    I also tried to change mysql-x-x-connector driver but without solving my problem.
    Can someone help me ?
    Thanks
    Giorgio

    You'll find that it is more to do with the way MySql deals with dates than anything else! Depending on how your date field is setup, then try using a BETWEEN statement for those 2 lines in your first query e.g.
    AND ( tbl_tesserati.data_nascita BETWEEN ? AND ?)
    The date column needs to be in the ISO format to work. If you examine your second query output, you might discover that the output is only going to refer to one parameter (probably the OR one). Did you manage to view the output logs from the application server? You would have got an idea from there with a message like stating a conversion error'.
    Alternatively, you could try using the to_days() function and convert it directly to a number which would be a lot easier to deal with. For example:
    AND to_days(tbl_tesserati.data_nascita >= ? )
    AND to_days( tbl_tesserati.data_nascita<= ? )
    Or try the BETWEEN version with to_days() and see what you get.
    More info about date formatting (v5) here:
    http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days
    Before I forget, sometimes you may need to treat dates as Strings rather 'Long' as you did.
    As a matter of interest, did you try your query in a different piece of software?
    If my queries are a little more complicated, I tend to try MySql queries out in the free MySql query browser and also double check in another to verify certain issues. I found it easier to develop SQL in a seperate program then import the final version to JSC making the required modifications for parameters.
    Message was edited by:
    aerostra

  • Date Problem in Java with MySql

    Hello
    I am using Java with Mysql.I want to enter date in some in my format(YYYY:MM:DD:HH:MM:SS), this thing i have convert using format class and format class return date in String and iwwnat to insert this value in MySQL Table,So i want to know how can i convert String value in Date for Mysql is their inbuild function for converting string into date in mysql.
    Regards
    Anupam S

    Use PreparedStatement and SimpleDateFormat classes
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=%2BPreparedStatement+%2BSimpleDateFormat+&qp=siteforumid%3Ajava48&chooseCat=allJava&col=developer-forums&site=dev

  • Problem with cascading dependent LOV query running when it should not

    I have a page fragment with a regular ADF form on it that I use to add new entries to a table. This form has many fields on it with LOV’s associated with them. I have dependent LOV’s on some of them. The one case I have is I have three fields A, B, and C. Field C is dependent on A and B. The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time after I select it and before it is displayed on the form. If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away. My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it. I don’t really want to use the rownum in the where clause.

    i had lot of question?
    The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time
    ok. are using? any complex query to pick the lov 'a' .
    Answer: The LOV for A is based on a read only non-EO view with a SQL that is not really very complex. The LOV definition does set multiple values when the selection is made to blank out dependent fields in the data model used by the main form.
    after I select it and before it is displayed on the form.
    here i cant undestud?
    Answer. The order of things is I open the main form, I click the mag glass to open the LOV popup, I select the row I want and click the OK button. Navigation returns to the main form where I get the hourglass waiting for the selected value to be displayed in the field on the main form.
    If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away.
    ok.
    why are you going to delete the value of c?. At intial stage you can make empty after selecting a and/or b you can load into c.
    Answer: I physically deleted field C from the main form to see if that was what was causing the long delay. When I run the main form without field C I do not get the hourglass. That is how I know they are related.
    My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it.
    you may set partial trigger to c depends for 'a'.
    or else lov 'c' query depends on 'a'
    Answer. The query for C's LOV does depend on the value returned when I select a value for A. They are cascading LOV's. Will setting the partial trigger stop the SQL for field C from running? Is the SQL running because I'm blanking out field C when I change the value for field A?
    am not sure i understud correctly. can you pictuarize you problem with an example.

Maybe you are looking for