Connecting database to Servlets

Hi i am trying to connect MySql to a simple servlet program. The MySql server gets started and the tables and data are retrievable, and the servlet is compiled, but unable to run the servlet in the browser. I get a blank page when i run the program in the browser.
I have set all the classpaths right, and have mapped the class file in the web.xml. This is my servlet program:
import java.io.*;
import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class servsql extends HttpServlet
        public void doGet(HttpServletRequest req, HttpServletResponse res) throw
s ServletException,IOException
                Connection con=null;
                Statement stat=null;
                ResultSet rs=null;
                String username="root";
                String password="tellno11";
                String url="jdbc:mysql://127.0.0.1/goldendb";
                try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection(url,username,password);
                stat=con.createStatement();
                rs=stat.executeQuery("select * from emp");
          res.setContentType("text/html");
                PrintWriter out= res.getWriter();
                while (rs.next())
                out.println("<html>");
                out.println("<head><title>First SQL Program</title></head>");
                out.println("<body>rs.getString(1)</body>");
                out.println("</html>");
               } catch(Exception e) {  }
}Any suggestions of how to fix the problem?
Thanks,
Nive

Hi i am trying to connect MySql to a simple servlet
program. The MySql server gets started and the tables
and data are retrievable, and the servlet is
compiled, but unable to run the servlet in the
browser. I get a blank page when i run the program in
the browser.
I have set all the classpaths right, and have mapped
the class file in the web.xml. This is my servlet
program:
import java.io.*;
import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class servsql extends HttpServlet
public void doGet(HttpServletRequest req,
est req, HttpServletResponse res) throw
s ServletException,IOException
Connection con=null;
Statement stat=null;
ResultSet rs=null;
String username="root";
String password="tellno11";
String
String
String url="jdbc:mysql://127.0.0.1/goldendb";
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection(url,username,password
stat=con.createStatement();
rs=stat.executeQuery("select * from
y("select * from emp");
          res.setContentType("text/html");
PrintWriter out= res.getWriter();
while (rs.next())
out.println("<html>");
out.println("<head><title>First SQL
<title>First SQL Program</title></head>");
out.println("<body>rs.getString(1)</body>");
out.println("</html>");
} catch(Exception e) {  }Put a print statement inside the bracket to print the exception like
System.out.println(e);
and check whether there is any exception or not
>
regards
shanu

Similar Messages

  • Connecting database in Servlet vs App

    Hi,
    Windows 2000 Server / SQL Server 2000 / Tomcat
    I have a class managing the connections and requests to databases.
    When invoking it from a java app context (launched from the command line java myApp), it's working fine
    but when the same connection is made from a servlet, the Class.forName(dbDriver) doesn't work. I don't have a specific messsage, the Exception e.getMessage() returns only the driver used to access the database.
    Have any idea ?

    here is the test I made, creating a servlet as simple as possible :
    public void doGet(HttpServletRequest requete, HttpServletResponse response) throws IOException, ServletException{
    test( response );
    public void test(HttpServletResponse response){
    boolean correct = true;
    PrintWriter pw = null;
    try{
    response.setContentType( "text/html" );
    pw = response.getWriter();
    catch(Exception e){ correct = false;}
    if ( correct ){
    try{
    Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ).newInstance();
    catch( Exception e ){
    pw.println( "Error : " + e.getMessage() );
    the Class.forName send me in the Exception.
    The message is Error : com.microsoft.jdbc.sqlserver.SQLServerDriver
    I'm running Windows 2000 Server, SQL Server 2000, Microsoft SQL Server 2000 Driver for JDBC, Tomcat 5.5, JRE 1.5.0
    The same Class.forName is ok when called from the main of a java App.

  • Connecting database in servlet

    I am trying to connect to the database in a servlet but it throws a ClassNotFoundException.
    the problem is when i am trying with the same piece of code in a simple java class. it works perfectly fine.
    Server i am using is - Jakarta-Tomcat 5.
    driver - com.microsoft.sqlserverdriver.SQLServerDriver.
    all the packages imported are also the same..
    Can any one suggest a solution to this...

    Did you put the sqlsever jdbc jars in WEB-INF/lib, or is it on Tomcat's classpath?

  • Cannot connect to database with servlet thru apache http server / vhosts

    Hello,
    I have an application that works perfectly when Tomcat 5.5 is running stand-alone, but when I run Tomcat and Apache HTTP Server together, I get an error when trying to connect to the database. Servlets are working fine otherwise. Connection pooling is setup and working fine for Tomcat stand-alone. With the Apache server, I'm running Virtual Hosts.
    My guess is that I need something in the host block of server.xml about the context.xml where the db resource pool is defined. This is what I have so far in server.xml:
    <Host name="www.mydomain.com" debug="0" appBase="d:/WebApps/mydomain"
    unpackWARs="true" autoDeploy="true">
    <Context path="" docBase="" debug="0"/>
    </Host>
    Or the problem may be caused by something else entirely. Does anybody have any suggestions? Your help is greatly appreciated.
    Thank you,
    Logan

    A little help? Anybody?
    I can connect to the database with Tomcat stand-alone, but not with Tomcat integrated with Apache. I have seen this problem described elsewhere, but no solution has been found.

  • HELP IN DATABASE CONNECTIVITY IN A SERVLET`

    HI there,
    I have some issues in an application. I have a servlet which is called Servlet1.class. I have deployed this in my tomcat webapps folder. There is a stand alone application called MailAgent.class which pools into a mail box and retrieves the messages and converts them as HTTP messages. Then the MailAgent.class sends the HTTP message as multipart post (email message) to the servlet. In the servlet I am trying to establish a database connection with the JDBC driver from third party vendor. I am unable to get the driver class when I establish the connection with the database. Is there any issues with servlet and database access. I am able to connect if I run as a stand alone application.
    Any help would be greatly appreciated.
    Thanks
    John

    There shouldn't be any .class file in your webapps folder. I hope you mean that you created a subdirectory under webapps, with a WEB-INF under that and /classes and /lib under that. Your servlet .class file and its package directory structure belong under webapps/yourApp/WEB-INF/classes, right?
    You can create database connections in a servlet, although I agree with the previous poster that you'd be better off putting database code into objects that you could test off-line, without the servlet.
    You've got to have the JDBC driver JARs in the webapps/yourApp/WEB-INF/lib directory, for starters.
    If you get really adventurous you can create a pooled JNDI data source, but maybe that's another day's work. Get the basic connection working first.

  • Connecting to MySQL Database with Servlet

    Hi All,
    I want to connect to MySQL Database from servlet.
    I am using Tomcat websever 3.3.1, where i have to set classpath of mysql jdbc driver.
    I tried by copying mysql jdbc driver in so many directiories of Tomcat server but it is
    giving me error like "no specified driver find"
    So please send me all the solutions and how to set the classpath to connect to
    mysql database.
    Thanks

    U r correct that so many people are giving me solutions but that are not working for me
    I think i not correct in setting the classapath to mysql jdbc driver.
    1)I have unjarred correctly and all the classes are present in that.
    yes driver class is there in that .
    2)Now i am using new version of the mysqljdbc that is 2.0.13
    If now any driver after this send me url i will download it and use it
    3)I am unable to under stand what is yourcontext in
    yourcontext/web-inf/lib?
    This is my directory structure.
    c:tomcat in this i have
    bin
    conf
    doc
    lib
    logs
    modules
    native
    webapps
    work
    in bin there are no subdirectories
    in conf i have
    auto,jserv,jk,users
    in doc i have
    appdev,images
    sample( in appdev)
    etc,lib,src,web(in sample)
    images(in sample\web)
    in lib i have
    apps
    common
    container(c:\tomcat\lib)
    in logs,modules there are no subdirectories
    in native (c:\tomcat\native) i have
    mod_jk
    mod_jserv
    in mod_jk i have
    apache 1.3
    common
    iis
    jni
    netscape
    nt_service
    in webapps i have (c:tomcat\webapps)
    Admin,Examples,root
    in Admin i have (c:\tomcat\webapps\admin)
    contextadmin
    Meta-inf
    Test
    Web-inf
    in web-inf (c:\tomcat\webapps\admin\web-inf)
    Classes,lib,script
    in classes i have (c:\tomcat\webapps\admin\web-inf\classes)
    tadm
    in examples (c:\tomcat\webapps\examples) i have
    Images,Jsp,Meta-inf,Servlets,Web-inf
    in web-inf (c:\tomcat\webapps\examples\web-inf) i have
         Classes,jsp
    in classed (c:\tomcat\webapps\examplesweb-inf\classes) i have
    Cal
    Checkbox
    Colors
    Dates
    Error
    Examples
    Num
    Sessions
    in jsp (c:\tomcat\webapps\examples\web-inf\jsp) i have
    applet          
    I think this is enough to give correct answer for me .
    Thanks

  • Connection to the Database thru Servlet

    Hello:
    I have just read some threads in this forum and noticed that people saying that connecting to the database in JSP is not a good Java Programming Habit. So, could you please give a little guidance on connection to the Oracle database in servlet. Thank you very much.
    Oscar.

    You use standard JDBC:
    http://java.sun.com/docs/books/tutorial/jdbc/index.htmlIn a servlet container, most of the time, you set up a connection pool that you access through JNDI
    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.htmlFor larger applications you might want to use "Data Access Objects"
    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.htmlCheers,
    evnafets

  • Failed to open the connection - database vendor code 17

    I'm upgrading a VB.net Windows Forms application from 1.1 to 4.0.  In the reporting form, the list of reports you can choose are pulled from a folder where the .rpt files reside.  Once the user chooses a report and executes it, vb code populates the current database connection information and displays the report in the report viewer control.
    The following things are true:
    - Version 1.1 works on my systems and my customers systems
    - The code has not been changed, except that it now targets .Net 4.0 instead of 1.1
    - The exact same .rpt files are being used
    - Version 4.0 connects to the same database my customer is using, and I can run the reports just fine from here.
    - Version 4.0 is able to connect to the database just fine from my customers systems (using the same connection information provided to the report)
    - My customer installed this:  http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_redist_install_32bit_13_0_2.zip
    The only problem is that my customer encounters this error when trying to run any report from his systems:
    Failed to open the connection.
    Details:  Database Vendor Code: 17
    Failed to open the connection.
    Orders.BOL.TaskDetail {393C9017-0ED1-4E1E-8824-E222F4B9D14C}.rpt
    Details:  Database Vendor Code: 17
    I read all of the articles I could find, and they either don't describe this exact situation, or there is insufficient information for troubleshooting this issue.  Are there steps that I've missed to make Crystal Reports for VS2010 work on my customer's systems?
    Your help is appreciated,
    Mark

    Hi Mark,
    More information required -
    - Does this happen with all reports or few?
    - What is the connection type used for the report to connect to the database (OLEDB,ODBC etc)
    - Are you changing the database at runtime?
    few things you could check
    - Check if the database is accaessible from the client machine with proper permissions / rights.
    - If its an ODBC connection check if the DSN with same name is created on the client machine.
    - Check the driver / provided used by the report to connect to the DB, verify that the same is installed on the client machine. (SQL NAtive client, SQL Server etc)
    Also take a look at below articles discussing the simillar issue.
    [CR for VS2010: Failed to Open Connection [Database Vendor Code: 17 ]|CR for VS2010: Failed to Open Connection [Database Vendor Code: 17 ]]
    [1474461 - Unknown Database Connector Error when connecting to a Dataset in a VS .NET application |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333433373334333433363331%7D.do]
    Hope this helps,
    - Bhushan.

  • Unable to connect database by DataSource in tomcat5.5 plz help to me

    hi,
    i want to connect Database through DataSource in Tomcat5.5 with mysql
    i wrote one servlet , made change in server.xml, web.xml.
    when i access it show exception
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.org.apache.tomcat.dbcp.collections)
            at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
            at java.security.AccessController.checkPermission(AccessController.java:427)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
            at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)The servlet
    * DataSourceAccess.java
    * Created on August 22, 2005, 3:14 PM
    package officecom;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.sql.*;
    * @author Paramasivam
    * @version
    public class DataSourceAccess extends HttpServlet {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet DataSourceAccess</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet DataSourceAccess at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            out.println(" got connection ?  "+getDataConnnecion());
            out.close();
        public boolean getDataConnnecion(){
            try{
                System.out.println(" INFO : getConnection called     ");
                Context initContext = new InitialContext();
                Context envContext  = (Context)initContext.lookup("java:/comp/env");
                DataSource ds = (DataSource)envContext.lookup("mysql");
                Connection con = ds.getConnection();
                if( con != null ){
                    return true;
                }else
                    return false;
            }catch(Exception e){
                e.printStackTrace();
                return false;
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo() {
            return "Short description";
        // </editor-fold>
    }Changes in server.xml
    <GlobalNamingResources>
          <Resource
          name="mysql"
          auth="Container"
          type="javax.sql.DataSource"
          password=""
          driverClassName="com.mysql.jdbc.Driver"
          maxIdle="2"
          maxWait="5000"
          username="root"
          url="jdbc:mysql://localhost:3306/sushi?autoReconnect=true"
          maxActive="4"/>
      </GlobalNamingResources>changes in web.xml
      <resource-ref>
               <description>Tomcat DBCP</description>
               <res-ref-name>mysql</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
    </resource-ref> 

    You might have more answers if you post this same question in the Sun Java Studio Enterprise forum...
    http://swforum.sun.com/jive/category.jspa?categoryID=90

  • ALC-TTN-105-000 could not connect to bootstrap servlet

    hi i am trying to install livecycle server using Adobe LiveCycle Configuration Manager on windows 7.in this i reached to a slide heading is LifeCycle ES3 Database initialization there is a button labeled as initializa and two text field in host text field i entered localhost and in port i entered 8080 and getting error
    ALC-TTN-105-000 could not connect to bootstrap servlet.Port[Connection refused:connect] may be invalid .
    i tried other ports also 8081 8085 9090 etc but still facing the same error .can any one please tell how to resolve this error??please help i am a beginner and i am very excited to create my first app please help how to proceed further and resolve this issue!!

    sorry, the discription was not clear. I would like to replenish this. This scene was to initialize the LiveCycle ES2 database and with the host: localhost and the HTTP port: 8080
    And I tried to start the jboss and found out, there is no directory of the jboss under /opt/jboss.
    thanks

  • Retrieve multiple images from database to servlet

    Hi there,
    I try to retrieve more than one images from database to Servlet/JSP . However, I get only one images in the result set. Here is my code. Please Help .
    How do I display more than one images ( multiple rows ) from database to Servlet ?.
    When I retrieve, I got 3 rows of binary data, but I don't know how to display it on the Servlet/JSP pages.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.sql.*;
    import com.sybase.jdbcx.*;
    public class RetrievePhoto extends HttpServlet {
    static ResultSet rs;
    static CallableStatement NGSstmt = null;
    static Connection NGScon = null;
    static SybDriver _driver = null;
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws
    ServletException, IOException {
    ServletOutputStream os = res.getOutputStream();
    String driver = ""
    String URL = "";
    String Host = "";
    String UN = ""; //assign your username here
    String PW = ""; //assign your password here
    try {
    Class c = Class.forName( driver );
    _driver = (SybDriver) c.newInstance();
    DriverManager.registerDriver( (SybDriver) _driver );
    NGScon = DriverManager.getConnection( URL + Host, UN, PW );
    } catch ( SQLException e ) {
    os.println( "Unable to load the Sybase JDBC driver. " + e.toString() );
    e.printStackTrace(System.out);
    } catch (java.lang.Exception ex) {
    // Got some other type of exception. Dump it.
    os.println("Exception - java lang " + ex.getMessage() );
    String PID = req.getParameter("PID"); //passing parameters from Servlet
    try {
    String SQLcmd = "{call RET_PHOTO_BY_PID(?)}";
    NGSstmt = NGScon.prepareCall( SQLcmd );
    //execute the query
    synchronized (NGSIDBstmt)
    NGSstmt.setString(1, PID); //passing parameter to store procedure
    rs = NGSstmt.executeQuery();
    byte[] stuff = new byte[1024];
    int bytesRead = 0;
    res.setContentType("image/gif");
    InputStream is = null;
    // Get the first row
    while( rs.next() ) {
    is = rs.getBinaryStream("PHOTO");
    res.setContentLength(is.available());
    for (int i=0;; i++) {
    bytesRead = is.read(stuff);
    os.write(stuff);
    if ( bytesRead == -1 ) break;
    rs.close();
    os.flush();
    os.close(); //close outputstream
    } catch ( SQLException sqle) {
    os.println("Error in SQL2Exception" + sqle.getMessage());

    When I retrieve, I got 3 rows of binary data, but I don't know how to display it on the Servlet/JSP pages.I will pick this bit of your post, because you seemed to have several partly-overlapping questions.
    You are going about this wrong. You need to decide what your HTML will look like before you start writing servlet code. In this case you want to have something like a table, with an image in each row, right? Now what does the HTML for that look like? It's a <table> element, and so on, but what about the images? Well this is HTML, so it can't contain the binary images. It has to contains links to the images, and the browser will download the image from each of those links and put all of the downloads together into the page it displays.
    That means you can't do it all with one servlet. You need a main servlet that generates the HTML, with the <table> element and the links to the images. Probably you need some DB calls here to find out how many images you're going to have, but you don't need to get them in this servlet. You just need to generate a link for each of them.
    Then you need a second servlet that gets an image. It's going to get a single row from the DB and return the binary image you read from that row. Make sure to use "image/jpg" or whatever's appropriate instead of "text/html" in your response's content type here.
    I will leave you to carry on from here. First step is to design the HTML that your main servlet will produce; remember that the links it generates need to carry enough information for the second servlet to be able to find the right image in the DB.
    PC&#178;

  • Databases and servlets

    I'm writing an application that displays all the records in a database using servlets, everything works as it should when run under Tomcat 3.2.3. I've since installed the Win32 version of Apache and the JServ plugin. This works fine except when asked to run the servlet that accesses a database. The servlet loads OK but an exception is thrown when accessing the records (See below). Does anybody have any ideas why this is? Thanks.
    Exception thrown:
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    If you're using the jdbc-odbc bridge that ships with the Java api's, then you need to create the Driver and the Connection.
    You need lines that look something like:
    Driver driver = (Driver) Class.forName(driverName).newInstance();
    Connection con = DriverManager.getConnection( dataSourceURL, UserName, Password);

  • How to delete a record in a connected database?

    We are encountering a problem using the delete function for removing a record in a connected database table. The database is an excel-file and we are able to add a new record, update existing records but not delete records. We are using the following script in FormCalc since I read that the function does not work in JavaScript:
    $sourceSet.DataConnection.delete()
    The error message returned is:
    "Deleting data in a linked table is not supported by this ISAM."
    We are also curious to know how we can reload the connection so that for example a drop-down list containing values from each record in the table is updated automatically when we insert a new record.
    Thanks!
    Annika

    You also asked:<br /><br /><font color="grey"><i>We are also curious to know how we can reload the connection so that for example a drop-down list containing values from each record in the table is updated automatically when we insert a new record.</i></font><br /><br />You should be able to achieve this quite easily using the Data Drop Down List from the Library palette's Custom tab. This object has a pre-defined Initialize script which populates the list with items from a data connection you specify.<br /><br />While the object is pre-configured to load items from the data connection only upon initialization (which only occurs when the form is loaded and after a data merge), you could move the script into a Script Object function and call it whenever you insert a new record (just after the statement which inserts the record).<br /><br />This is the script from the Initialize event of the Data Drop Down list put into a Script Object function called LoadDropDownList which takes the drop down list to populate using the data connection as a parameter:<br /><pre>function LoadDropDownList(oDropDownList)<br />{<br />     /*     This dropdown list object will populate two columns with data from a data connection.<br />     <br />          sDataConnectionName - name of the data connection to get the data from.  Note the data connection will appear in the Data View.<br />          sColHiddenValue      - this is the hidden value column of the dropdown.  Specify the table column name used for populating.<br />          sColDisplayText          - this is the display text column of the dropdown.  Specify the table column name used for populating.<br />     <br />          These variables must be assigned for this script to run correctly.  Replace <value> with the correct value.<br />     */     <br />     <br />     var sDataConnectionName = "&lt;value&gt;"; //     example - var sDataConnectionName = "MyDataConnection";<br />     var sColHiddenValue = "&lt;value&gt;"; //     example - var sColHiddenValue = "MyIndexValue";<br />     var sColDisplayText = "&lt;value&gt;"; //     example - var sColDisplayText = "MyDescription"<br />     <br />     //     Search for sourceSet node which matchs the DataConnection name<br />     var nIndex = 0;<br />     while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)<br />     {<br />          nIndex++;<br />     }<br />     <br />     var oDB = xfa.sourceSet.nodes.item(nIndex);<br />     oDB.open();<br />     oDB.first();<br />     <br />     //     Search node with the class name "command"<br />     var nDBIndex = 0;<br />     while(oDB.nodes.item(nDBIndex).className != "command")<br />     {<br />          nDBIndex++;<br />     }<br />     <br />     //     Backup the original settings before assigning BOF and EOF to stay<br />     var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");<br />     var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");<br />     <br />     oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction");<br />     oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction");<br />     <br />     //     Clear the list first so that we replace any existing items<br />     <b>oDropDownList</b>.clearItems();<br />     <br />     //     Search for the record node with the matching Data Connection name<br />     nIndex = 0;<br />     while(xfa.record.nodes.item(nIndex).name != sDataConnectionName)<br />     {<br />          nIndex++;<br />     }<br />     var oRecord = xfa.record.nodes.item(nIndex);<br />     <br />     //     Find the value node<br />     var oValueNode = null;<br />     var oTextNode = null;<br />     for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++)<br><br />     {<br><br />          if(oRecord.nodes.item(nColIndex).name == sColHiddenValue)<br><br />          {<br><br />               oValueNode = oRecord.nodes.item(nColIndex);<br><br />          }<br><br />          else if(oRecord.nodes.item(nColIndex).name == sColDisplayText)<br><br />          {<br><br />               oTextNode = oRecord.nodes.item(nColIndex);<br><br />          }<br><br />     }<br />     <br />     while(!oDB.isEOF())<br />     {<br />          <b>oDropDownList</b>.addItem(oTextNode.value, oValueNode.value);<br />               oDB.next();<br />     }<br />     <br />     //     Restore the original settings<br />     oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction");<br />     oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction");<br />     <br />     //     Close connection<br />     oDB.close();<br />}</pre><br />The required modifications to the original script are in bold.<br /><br />The easiest way to create the Script Object is to right-click on the top-level form object ("form1" by default) in the Hierarchy palette and select the <i>Insert Script Object</i> option. This will insert an un-named Script Object which you should then rename to something meaningful like, "ScriptObject". Once you've done this, you can call the function from any event on any object on your form with the following JavaScript:<br /><pre>ScriptObject.LoadDropDownList(&lt;SOM expression for drop down list&gt;);</pre><br />If you were calling this function on an "add record" button's Click event, the drop down list was named "DropDown" and both objects were in the same subform, you would do this:<br /><pre>ScriptObject.LoadDropDownList(DropDown);</pre><br />Stefan<br />Adobe Systems

  • Urgent: how to run applet which connected to the servlet?

    hi frends:
    i have written an applet on the server side and it supposed to pass parameters to my servlet and retrieve some info from the servlet.
    i put both applet and servlet under tomcat../WEB-INF/classes. but when i run the applet from the web browser, there is no response from the servlet.
    could anyone help me to solve this problem?
    one more thing is i know that applet is able to connect to servlet, but how about java application? is it able to do so? if yes, is it also using URLconnection as applet? and how to run it?
    i will be very appreciate if anyone can help me... thanx a million.

    You can connect to the servlet from an application.There's a URL class in java.net that has an openConnection method. Then cast the return to an HttpURLConnection and use setMethod to set up as a post request.This may be the default if you call setDoOutput(true) on the URLConnection. Then you'll need to get an OutputStream and write properly formatted form POST data to it. It's also possible to encode your data on the URL, even when using the POST method, and this may be easier when doing it programmatically from an application. To send a get request you can append the name-value pair at the end of the url.

  • Connect database using ext javascript or applescipt in indesign

    Hi,
    I need to connect oracle database using extended javascript or apple script in indesign. Can somebody help by giving any suggestion. Or is there any possibility to connect database using the two scripting methods.
    It  is really urgent.
    Thanks
    Karthik B

    ExtendScript has a Socket object prototype you can use to e.g. connect to the internet. Calling a web service would probably be more elegant than addressing the database directly. Socket is fairly low-level, though. If you need something easier, you could always try out http://extendables.org/docs/packages/http/doc/readme.html
    I seem to recall some InDesign plug-ins you could buy that allow you to connect to a database directly, but you'd have to google that yourself.

Maybe you are looking for

  • Mini Displayport DVI Adapter Problem

    I'm currently having issues with my MacBook Pro's DVI out (via Apple Mini-Displayport Adapter). Whenever my displays go to sleep (which is set after an hour) and wakes up, sometimes the external display (a SyncMaster 220WM) shows "snow" or "static" .

  • When is the unlocked iPhone 5 likely to be available in the US??

    by when is the unlocked iPhone 5 likely to be available in the US??

  • How can i take Basic price value as Net value in sales order

    Hello SD experts, I have constructed a pricing procedure, and in that have taken condition type for basic price as rate (cond. type= Price) and have another 3 condition types as surcharges for some internal calculation (but i have to show them in pri

  • CS5 in Yosemite problems loading

    Anyone got any ideas why, since I installed Yosemite on my iMac, Photoshop CS5 won't load. It starts, but hen I get an error window and it quits. I have uploaded the Java update. The message I get is this!

  • Windows Speech Recognition Macros - Wait for Second Command

    Hello all. 'm terribly sorry if this was posted in the wrong forum. Let me know where to put it and I'll move it accordingly. I'm working with Windows Speech Recognition Macros, and I've got a question. Is there ANY way to write a macro that is trigg