Help With Servlet+JDBC Example?

hi there
i've made my first jsp page
that contain two textfields name&description
and i want that when the user presses the add button
the information is sent to the servlet and the servlet add the information in the database
how that can be done in the servlet?
thank you

You can extends the httpservlet, then implements the method of the doGet,and you can do what you want to do。
it is easy, u had better find some book to read。

Similar Messages

  • Help With Servlet & SQL

    I'm working on a project for my Java class and I'm running into trouble with the JDBC section. My project is laid out as follows:
    This project consists of a HTML page, a servlet, and a database. I have already wrote up the code for the interaction between the login page and the servlet, however, I cannot figure out how to use java to interact with a Microsoft Access database.
    I'm trying to call to a method (which has the coding for JDBC & SQL) by calling to it through the doPost method. The program refuses to go to that method. I'm not sure if it's a syntax error or if it's not even allowed in Java. I think I've narrowed the problem down to this line:
    String user = getUser(username, password);
    getUser is the method I was refering to in the previous paragraph. When getUser as it's own class, without dealing with paramters, it works fine. When I calling it with parameters, it doesn't seem to work. It will not even return a string when I call it. If you need the getUser code, I can provide it.
    I hope I am being clear, if not please let me know. Thanks in advance for any help you can provide. It is much appreciated.

    I'm trying to call to a method (which has the coding
    for JDBC & SQL) by calling to it through the doPost
    method. The program refuses to go to that method. I'm
    not sure if it's a syntax error or if it's not even
    allowed in Java. I think I've narrowed the problem
    down to this line:
    String user = getUser(username, password);
    getUser is the method I was refering to in the
    previous paragraph. When getUser as it's own class,
    without dealing with paramters, it works fine. When I
    calling it with parameters, it doesn't seem to work.This the part that is a little confusing.
    You should always be able to call a method. The method may not return anything, but if the method exists and you supply the correct parameters, you can call it, or as you put it, "go to it". I.e.,
    public void doGet( HttpServletRequest request,
                       HttpServletResponse response ) {
       ... // some code that defines the output stream as "out"
       out.println( "The user's name was " + getUser( username, password ) );
    }Would work. You've "gone to" the method.
    That is a completely seperate problem from the getUser() method not working when you provide parameters. I suspect getUser() isn't working because you either provide the incorrect parameters, or you're expecting the wrong return value.
    This is one of those examples when being able to see your code would really help.
    However, I can make a guess... You've defined the function as:
    String getUser( username, password ).
    I would guess getUser() takes the username expressed as a string, the password expressed as a string, and returns what... the username as a string? In which case, why do you need getUser()?
    Another possibility is that Microsoft Access isn't really a multi-user application, I don't think it requires you to log in and present your credentials (the password). That may explain why it works when you call getUser() without any parameters.

  • Help with Servlets!!

    Hi all,
    I need help with Java and Jsp. Here are the specs:
    1. An HTML web form that contains info about a customer: name, address, telephone number.
    2. When the "Submit" button is clicked, the information will go directly into an Oracle database table named "customer".
    Where should I start?? So far, I have created the HTML web form. So what i need is to write a servlet that will take the data from the web form and insert that into the Oracle table. If you have any solutions to my problem, please let me know. Thanks a lot in advance.

    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head>
    <title>
    Customer
    </title>
    </head>
    <body>
    <%!
    java.sql.Connection con;
    java.sql.PreparedStatement pstmt;
    java.sql.ResultSet rs;
    javax.servlet.http.HttpServlet request;
    String name,address;
    int phone;
    int i;
    %>
    <%
         try {     
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = java.sql.DriverManager.getConnection
    ("jdbc:odbc:<DSN name>","scott","tiger");
    %>
    <% } catch(Exception e){ System.out.println(e.getMessage()); } %>
    <%
    name = request.getParameter("name");
    address = request.getParameter("address");
    phone = Integer.parseInt(request.getParameter("phone"));
    pstmt=con.prepareStatement("insert into <table name> values(?,?,?)");
    pstmt.setString(1,name);
    pstmt.setString(2,address);
    pstmt.setInt(3,phone);
    i=pstmt.executeUpdate();
    %>
    </body>
    </html>
    1. create a dsn connecting oracle, using ODBC from control panel
    2. name the text fields in the html page as "name","address","phone"
    3. enter the table name you created in oracle in place of <table name>
    I hope this should work , let me know .......
    bye
    vamsee

  • Need help with CONTACT sync example

    I have been trying to work with the Sync example that utilizes the MEREP_CONTACT_* BAPI wrappers.  Is there anyone who has been able to get this example to work that could give more information on it?  I can create the programs, but cannot get data to it.  Which SyncType is it supposed to use?  What directory do you create the data from MEREP_SAP_EXM002_DATA_GEN1?
    Any information would be greatly appreciated.
    Thanks
    Brian Timothy
    [email protected]

    hello brian,
    i created the contactaddress test application and used these BAPIs on the backend mapped to syncBos SAP_EXM001 and SAP_EXM002. the basic requirement for this is to deploy your application together with the xml metadata.
    after your application is installed in the ME, the framework will automatically send a data download request for syncBos SAP_EXM001 and SAP_EXM002 on the next synchronization. Prior to this, the application tables in the backend like the MEREP_PERSON which is mapped to the syncbo SAP_EXM002 should be filled with data.
    use MEREP_SAP_EXM002_DATA_GEN2 and MEREP_SAP_EXM001_DATA_GEN1 to fill-up the tables with data.
    you should have at least a data viewer for the corresponding syncbo data on your application.
    hope this helps.
    regards
    jo

  • Help with servlet

    I have a project with servlets in the 2 following folders
    myprojects and myclasses
    In my projects I have the helloProject and inside it I have the helloHtml folder and the helloPackage.
    So in the helloHtml folder I have the hello.html file and in the helloPackage I have the Hello.java (which is the servlet)
    when I compile this .java file the class file is inserted in the file myclasses\helloProject\helloPackage
    First in the file hello.html I have the code
    action="http://localhost:8080/servlet/helloPackage.Hello
    and so the servlet is executed fine.
    The problem is that I need to put a button in the code of Hello.java
    so that I can have reloaded the first page which is the hello.html
    But I am confused if I write onclick=history.go(-1) I have what I want but this page is not reloaded so I have some parameters there that I do not want
    Can I write sth like onclick=location.href=http://locahost:8080/.....??
    Could you please give me an advice considering the above description of my files??
    Thank tou very much....

    use sendRedircet(String AbsoluteURL) to send the Browser a redirect header so the browser send a new (fresh) request to the serlvet (with any parameter you specified).

  • Need Urgent Help with Servlets!!!

    I was just assigned a java project few days back and the thing is that i noe nuts abt JAVA!!! My first time and i admit i'm a slow learner.
    I was tasked to develop a servlet for web based query of inventory status in FIFO storage from QIS database.
    Basically, i heard according to my supervisor that this is a very simple project that may be completed in just days..but as i said this is my first Java program and i really need u guys to help me!!!! I have no idea how to start the entire coding process.
    The main page where the option buttons are is actually a form. This program have a HTTP extension i think. Below i have indicate the System and User Requirements.
    System Requirements
    * A Servlet
    * 2 option buttons
    * 1 for retrieving a Summarised Report
    * 1 for retriveving an Detailed Report
    * 1 command button for retrieval of data
    * Retrieved data will be displayed on another frame
    User Requirements
    * Be able to view Summarised Report at a click of a mouse
    * Be able to view Detailed Report also at a click of a mouse
    PLS HELP!!!!!!!!

    Justa comment...
    << according to my supervisor that this is a very simple project that may be completed in just days
    If your supervisor is so confident, then, maybe he/she should just get it done himself/herself. I really mean it. However, if that does happen, he/she should provide post-implementation support himslef/herself.
    In the meanwhile you can continue thinking about doing it the right way. Which is to first get some grasp of sorts about the various Java and other technologies and concepts you are talking about. Then have some kind of plan and follow it.
    I think at the end both you, and more importantly, your supervisor would see the difference in the result with respect to quality of work.
    Forums such as these provide an excellent wealth of information mostly because they are a means to consolidate knowledge gained by individuals from their past experience.
    However, in my opinion, it would be wrong to expect that one would be able to design and implement a real-life application just from information gathered from such forums. An example problem if you do it that way is: who will provide guaranteed support if something does not work in your real-life application. Your supervisor ?
    Instead, do the study part systematicaly. Try to convince your supervisor that thats the way to do it. Then do it. And come back with specific problems you might have.
    Best luck.

  • Help with Servlet-RMI

    I am planning to write a servlet which communicates with another java processes via RMI. This is necessary because the java process will act as a server serving requests from the servlet which will pass results to the client. I am new to RMI and would appreciate very much if anyone can direct me to some examples, docs or recommend books (even better) which might help..........
    many thanks in advnace

    Hi DevMentee (nishil?)
    First many thanks and I am new to RMI and I did look
    at Sun and JGuru's RMI stuff on the web(good on theory
    but short on real world examples like stockquoteserver
    etc..).Perhaps these Web pages contain the type of examples you are looking for (assuming you are unfamiliar with them)
    http://www.javaworld.com/isearch?qt=RMI&x=56&y=11&site=javaworld&ms=1&tid=1&st=1&rf=0
    http://www.fawcette.com/Archives/premier/mgznarch/javapro/1998/jp_nov_98/th1198/th1198.asp
    http://www.fawcette.com/Archives/premier/mgznarch/javapro/1998/jp_febmar_98/rk0298/rk0298.asp
    Yours links they will be very helpful...is
    there a particular site you would recommend for
    examples etc?Personally I liked Dick Baldwin's tutorials, but each person is different -- that's why I gave a variety of resources. Hopefully one of them will be good for you.
    MY servers are in C++ on NT implemented using MS
    stuff, so perhaps CORBA would not be possible, but
    perhaps I can access using COM which could be easier
    than JNI...I remember seeing mention of a third-party COM-java bridge library, but I can't give you any details, sorry :-(
    ALSO, I have one more question :-)
    Is it possible to run multiple RMI servers (processes)
    on the same machine? if so what would happen if
    multiple requests came thru using same port and host
    name....I haven't tried it myself. My guess is that it's possible. Why don't you just try it and see?
    Good Luck,
    Avi.

  • Need serious help with JSP + JDBC/Database connection

    Hey all,
    I have to build an assignment using JSP pages. I am still pretty new and only learning through trial and error. I understand a bit now, and I have managed to get a bit done for it.
    I am having the most trouble with a Login Screen. The requirements are that the a form in a webpage has Username/Number and Password, the user clicks Login, and thats about it. The values for the username/number and password NEED to come from the database and I cannot manage to do this. The thing I have done is basically hardcode the values into the SQL statement in the .jsp file. This works, but only for that one user.
    I need it so it checks the username/number and password entered by the user, checks the database to see if they are in it, and if so, give access. I seriously am stuck and have no idea on what to do.
    I dont even know if I have made these JSP pages correct for starters, I can send them out if someone is willing to look/help.
    I have setup 3 other forms required for the assignment and they are reading data from the db and displaying within tables, I need to do this with non-hardcoded values aswell. Im pretty sure I need to use for example 'SELECT .... FROM .... WHERE username= +usrnm' (a variable instead of username="john" , this is hardcoded), I just CANNOT figure out how to go about it.
    Its hard to explain through here so I hope I gave enough info. A friend of mine gave some psuedocode i should use to make it, it seems ok to follow, its just I do not know enough to do it. He suggested:
    get the username and pass from the env vars
    open the db
    make an sql (eg SELECT user, pass FROM users WHERE user = envuser)
    index.jsp points to login.jsp
    login.jsp get the vars you put into index.jsp
    opened the db
    is the query returns nothing - then the user is wrong
    OR if the passwords dont match
    - redirect back to index.jsp
    if it does match
    - set up a session
    - redirect to mainmenu.jsp
    Anyway, thanks for any help you can give.
    -Aaron

    Hi,
    Try this... it may help you...
    mainMenu.jsp
    <html>
    <body>
    <form method="POST" action="login.jsp">
    Username: <input type="text" name="cust_no">
    <p>
    Password: <input type="password" name="password">
    <p>
    <input type="submit" value="LOGIN">
    </form>
    </body>
    </html>
    login.jsp
    <%@ page import="java.io.*, java.sql.*"%>
    <html>
    <body>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:rocky");
    Statement statement = connection.createStatement();
    String query = "SELECT cust_no, password FROM customers WHERE cust_no='";
    query += request.getParameter("cust_no") + "' AND password='";
    query += request.getParameter("password") + "';";
    ResultSet resSum = statement.executeQuery(query);
    if (request.getParameter("cust_no").equalsIgnoreCase(resSum.getString("cust_no") && request.getParameter("password").equalsIgnoreCase(resSum.getString("password"))
    %>
    <h2>You are logged in!</h2>
    <%
    else
    %>
    <h2>You better check your username and password!</h2>
    <%
    }catch (ClassNotFoundException cnfe){
    System.err.println(cnfe);
    }catch (SQLException ex ){
    System.err.println( ex);
    }catch (Exception er){
    er.printStackTrace();
    %>
    </body>
    </html>
    I didn't check the code that I wrote. So you may have to fix some part of it. Also this may not be the best solution, but it will help you to understand the process easily.
    The more efficient method is to check whether the result set returned from the database is null or not.... I hope you got the idea... Good luck!
    Rajesh

  • Help with servlet and JSP

    I am creating a web application that allows users to submit questions and answers to a database. The users can also specify a number of questions and take a randomly generated test from the questions that have been submitted to the database. Currently, I am having trouble figuring out how to generate the test and then grade it. I was thinking I would use a question page that displayed a random question and its answers, allowed the user to answer the question and submit it, and then have the page reload with a new random question from the database. After the user has answered the number of questions they specified, then it would go to a results page with the percent and grade. I'm having trouble figuring out a servlet for the test generation. Any help would be much appreciated.
    Thanks, Mike
    [email protected]

    Please provide more information on exactly what the problem you are having is.
    For example: The following sentence you provide doesn't really say what the problem is:
    " I'm having trouble figuring out a servlet for the test generation."

  • Need help with Thin JDBC connecting Oracle to SQL server.

    I am fairly new to JAVA. We have ORACLE 8.1.7 running on Solaris 8. I have a need to
    periodically extract data from ORACLE DB and transfer it to SQL Server. I am limited to
    moving data from the ORACLE/UNIX environment to SQL Server side.
    From what I have read, Server-side Thin driver should work.
    1) Are there any issues in trying to achieve this with ORACLE running on the UNIX platform?
    2) Will the Server-side Thin driver talk to both the DBs ?
    3) Is it possible to provide some sample code ?
    Thanks in advance,
    Solomon

    Quattro,
    I had complete success in reading from Oracle and writing to SQL Server. First of all let me thank you for all your help. I do have one last request. Its more on optimization than any thing else.
    I was trying to optimize my code by grouping both the connections in one place and to keep my reads and inserts together so that I don't commit at the end of each insert etc. I don't seem to have the scope rules under control yet. Could you suggest how to improve this:
    import java.sql.*;
    public class Test_Combined2 {
    public static void main(String args[]) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    // You must put a database name after the @ sign in the connection URL.
    // You can use either the fully specified SQL*net syntax or a short cut
    // syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
    Connection con2 = DriverManager.getConnection ("jdbc:oracle:thin:@Test:1521:PSDEVElOP",
    "SOLOMON","SOL1");
    // Create a Statement
    Statement stmt2 = con2.createStatement ();
    String url = "jdbc:microsoft:sqlserver://INTRADEV:1433;DatabaseName=Measure";
    Connection con;
    String query = "select dataYear, dataMonth, yieldRate from tblYield " ;
    Statement stmt;
    try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.print(e.getMessage());
    // Select the ENAME column from the EMP table
    ResultSet rset = stmt2.executeQuery ("select year_start, monthofyear, percent_comp " +
    " from ps_usm_ytd_yield ");
    // Iterate through the result and print the employee names
    while (rset.next ()) {
    System.out.println (rset.getFloat (3));
    int ps_dataYear = rset.getInt(1);
    int ps_dataMonth = rset.getInt(2);
    float ps_yieldRate = rset.getFloat(3);
    try{
    con = DriverManager.getConnection (url, "tmpuser","tmppush");
    stmt = con.createStatement();
    PreparedStatement insertTblYield;
    String insertString = "insert into tblYield " +
    " values(?, ?, ?)";
    //con.setAutoCommit(false);
    insertTblYield = con.prepareStatement(insertString);
    insertTblYield.setInt(1, ps_dataYear);
    insertTblYield.setInt(2, ps_dataMonth);
    insertTblYield.setFloat(3, ps_yieldRate);
    insertTblYield.executeUpdate();
    con.commit();
    //con.setAutoCommit(false);
    /*ResultSet rs = stmt.executeQuery(query);
    System.out.println("dataYear, dataMonth, yieldRate");
    while (rs.next()) {
    int dataYear = rs.getInt(1);
    int dataMonth = rs.getInt(2);
    float yieldRate = rs.getFloat(3);
    System.out.println(" " + dataYear + ", " + dataMonth + ", " + yieldRate);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    } //while
    stmt2.close();
    con2.close();

  • Need help with servlets!!!

    Hi, I'm a beginner in Oracle and Servlets. So far I was able to make a servlet which could run a query to an existing table of an oracle database and return this data in an HTML form generated by that same servlet.
    I need some help on making a servlet that can accept user input and make an insert into that same existing table.
    null

    I suggest you break up the problem into manageable sub projects and solve each one in isolation. First, create a 'hello world' servlet. Search google for examples. Here is one problem with your code: if WelcomeServlet3 is in a package called 'myServlets, then you would use something like this: <servlet-class>myServlets.WelcomeServlet3<;/servlet-class> in the web.xml file.
    Next, is your database connection: I suggest you create a database connection in a class with a 'public static void main(String[] args) method to call it. Have the configuration data within the class. Dont get it from an xml file. This way, you can run it stand-alone by right clicking on the class and choosing 'run as application' and therefore ensure it works.
    Next go to the tomcat home page and read up on how to configure a database in tomcat by putting the configuration data in an xml file. Make sure you're reading the about the version of tomcat you're using. For all versions of tomcat, its something like this: If your web application is called 'myWebProject', then there should be an configuration xml file called 'myWebProject.xml' that goes under one of the tomcat sub folders. You use JNI to get the configuration data out of that xml file to configure the database. There is no database configuration data in the web.xml file.

  • Need help with Kerb. jdbc from Linux to MS SQL 2008

    Hello Forum, I am getting an erro when I try to use Kerb. trusted security to connect to sql server.
    4.0 documentation reflects it's absolutely possible.
    Not only that, I have ms odbc installed on the same box and it provides Kerbers (not ntlm) connection to sql server. But java with jdbc reject doing it.
    Here is the message:
    com.microsoft.sqlserver.jdbc.SQLServerException: Integrated authentication failed. ClientConnectionId:5836ac6c-6d2e-42e4-8c6d-8b89bc0be5c9
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:140)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.GenerateClientContext(KerbAuthentication.java:268)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
            at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
            at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
            at java.sql.DriverManager.getConnection(DriverManager.java:419)
            at java.sql.DriverManager.getConnection(DriverManager.java:367)
            at connectURL.main(connectURL.java:53)
    Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: com.sun.security.auth.module.Krb5LoginModule
            at javax.security.auth.login.LoginContext.invoke(LoginContext.java:834)
            at javax.security.auth.login.LoginContext.access$000(LoginContext.java:209)
            at javax.security.auth.login.LoginContext$4.run(LoginContext.java:709)
            at java.security.AccessController.doPrivileged(AccessController.java:327)
            at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:706)
            at javax.security.auth.login.LoginContext.login(LoginContext.java:603)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:133)
    1] Client side:
    Which OS platform are you running on? (Linux)
    Which JVM are you running on? (IBM J9 VM (build 2.6, JRE 1.6.0 Linux amd64-64
    What is the connection URL in you app? (jdbc:sqlserver://abcde24243.somebank.COM:15001;databaseName=master;integratedSecurity=true;authenticationScheme=JavaKerberos)
    If client fails to connect, what is the client error messages? (see above)
    Is the client remote or local to the SQL server machine? [Remote | Local]
    Is your client computer in the same domain as the Server computer? (Same domain | Different domains | WorkGroup)
    [2] Server side:
    What is the MS SQL version? [ SQL Sever 2008]
    Does the server start successfully? [YES ] If not what is the error messages in the SQL server ERRORLOG?
    If SQL Server is a named instance, is the SQL browser enabled? [NO]
    What is the account that the SQL Server is running under?[Domain Account]
    Do you make firewall exception for your SQL server TCP port if you want connect remotely through TCP provider? [YES ]
    Do you make firewall exception for SQL Browser UDP port 1434? In SQL2000, you still need to make firewall exception for UDP port 1434 in order to support named instance.[YES | NO | not applicable ]
    I currently can login from client using ms odbc sqlcmd (linux) version with trusted Kerberos connection.
    which tells me there is no problem with firewall.
    Tips:
    If you are executing a complex statement query or stored procedure, please use execute() instead of executeQuery().
    If you are using JDBC transactions, do not mix them with T-SQL transactions.
    Last but not least:
    gene

    Saeed,
    Not being versed in JAVA, I'm not sure what you're telling me. Can you tell me if this looks good? BTW, I did find out that JDBC is installed on the server as part of Coldfusion and this is what I was told:
    macromedia.jdbc.oracle.OracleDriver is 3.50
    macromedia.jdbc.db2.DB2Driver is 3.50
    macromedia.jdbc.informix.InformixDriver is 3.50
    macromedia.jdbc.sequelink.SequeLinkDriver is 5.4
    macromedia.jdbc.sqlserver.SQLServerDriver is 3.50
    macromedia.jdbc.sybase.SybaseDriver is 3.50
    Below is what I think will work, but I know it won't because of the semi colons. Can you help me fix it?
    I've the things that I think need changing are in bold.
    Thanks!
    ======
    private void dbInit()
    dbUrl = "jdbc:odbc:DRIVER={SQL Server};Database="DATADEV";Server=VS032.INTERNAL.COM:3533;", "web_user";
    try
    Class.forName("macromedia.jdbc.sqlserver.SQLServerDriver ");
    catch(Exception eDriver)
    failedDialog("Driver failed!", eDriver.getMessage());
    private void dbOpen()
    if(paramServerIP.indexOf("datadev") >= 0)
    dbPswd = "password";
    else
    dbPswd = "password";
    try
    dbCon = DriverManager.getConnection(dbUrl, paramDbUserStr,
    dbPswd);
    dbStmt = dbCon.createStatement();
    dbStmt.setEscapeProcessing(true);
    catch(Exception eDbOpen)
    failedDialog("Failed to open db connection!",
    eDbOpen.getMessage());
    private void dbClose()
    try
    dbStmt.close();
    dbCon.close();
    catch(Exception eDbClose)
    failedDialog("Failed to close db connection!",
    eDbClose.getMessage());
    }

  • URGENT please help with servlets

    am using Jbuilder 3 and there is no servlet classs to import .imported JSDK and the javax files. but it keeps saying my class does not extend http servlet any ideas!!

    I've used JBuilder3 a few times and as far as I remember the default Target jdk (version 1.2) cannot be changed or ammended and so you can't really import javax.servlet stuff.
    Go to project -> properties.
    You probably just need to define a new jdk version call it "JDK 12 Servlets" or something. It'll prompt you most of the way and then you just need to edit the Class path and add the javax stuff.
    Alternatively you can just save the file with jbuilder and do the compiliation from the command line.
    Hope this helps.

  • Help with Servlet Addressing

    I'll never, ever, as long as I live ever figure out where to put JSP stuff in my directories.
    in my tomcat I have an examples directory with a helloworld servlet...
    C:\jakarta-tomcat-4.1.12\webapps\examples\WEB-INF\classes\HelloWorldExample.class
    that I can access from my browser at URL...
    http://localhost:8080/examples/servlet/HelloWorldExample
    I've created a new directory on my tomcat to hold the website I want to develop...
    C:\jakarta-tomcat-4.1.12\webapps\dumfries
    In it I have copied the HelloWorldExample.class file so that it sits at address...
    C:\jakarta-tomcat-4.1.12\webapps\dumfries\WEB-INF\classes\HelloWorldExample.class
    But, after stopping/restarting the server I go to url
    http://localhost:8080/dumfries/servlet/HelloWorldExample
    I get "The requested resource (/dumfries/servlet/HelloWorldExample) is not available."
    The paths to the HelloWorldExample.class files in "examples" and "dumfries" are identical below the parent directory...
    C:\jakarta-tomcat-4.1.12\webapps\examples\WEB-INF\classes\HelloWorldExample.class
    C:\jakarta-tomcat-4.1.12\webapps\dumfries\WEB-INF\classes\HelloWorldExample.class
    And the url's follow the same address structure...
    http://localhost:8080/examples/servlet/HelloWorldExample
    http://localhost:8080/dumfries/servlet/HelloWorldExample
    but one works and the other doesn't!!
    WHY WHY WHY WHY (sound of hair ripping out) WHY WHY WHY

    Don't pull your hair out! The stress will make it fall out by itself!
    Besides, your answer is at your question in the other forum:
    http://forum.java.sun.com/thread.jsp?forum=33&thread=357756
    Also, check out some working code:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=357607

  • Help with NI-DAQ Example Code

    Hi. I've just started working with the NI ISB-6211. This is the first ACD i've ever used, so i'm farily new to this. I have quite a bit of knowledge in programming. After searching through the installation files I found some example C Code that runs in the command prompt. I've modified one quite a bit to get it to do what I want. My question is...
    Now, i'm having some issues. I'm trying to get it to print a voltage reading into the command prompt. I've hooked it all up and i've used labview to make sure everything is working as it should (Which it does!). When I compile the C program and run it, instead of returning a voltage it just aquires points, and I really have no idea what these "points" are.
    Here is the main part of the example code:
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,1.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
    // DAQmx Start Code
    DAQmxErrChk (DAQmxStartTask(taskHandle));
    // DAQmx Read Code
    DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));
    printf("Acquired %d points\n",read);
    Error:
     And then it just moves down to the exit clause. Is there any documentation anywhere which tells me which DAQ command I need to use to print a continuously updating voltage read out? (Just as a decimal, like 5.21V for example).
    Thank you all
    John
    Solved!
    Go to Solution.

    John,
    The data acquired by DAQmx is written into the array called 'data'.  The number of points DAQmx wrote into this array is stored in the variable 'read' which was passed in by reference.  To print the values returned, you'd need to loop over the 'data' array, and print each value.  See this help topic for an explanation of DAQmxReadAnalogF64.
    Dan

Maybe you are looking for