JSP - MySQL - MS Access

I have a set of tables in MS Access database and MySQL database.
My jsp application is running with the help of Apache/Tomcat in Linux box.
I've the MM.MySQL Driver to integrate MySQL with my application.
my problem is to know how to communicate jsp with MS Access here.
I don't know how to connect jsp to MS Access in Linux.
I searched for solution and finally got an idea of using MyODBC api.
I need to import data from MS Access to MySQL using MyODBC on Linux.
Can anyone help me on how to install,configure MyODBC and import data.
or please pass any reference url.
or
please suggest me any solution for this.
Thanks
Senthil

Thats what I meant. If both (Access and MySQL) both run on Windows there should be no problem. But if MySQL is on Linux and Access is on Windows it could be.
How about setting up Mysql on Windows, going the way magnoli supposed and after that using mysqldump to export zo linux.

Similar Messages

  • How to use taglibs in JSP for Database access

    Hi
    Could any one please tell me how to use taglibs in JSP for Database access
    with regrds
    Jojo

    This is a sample how to connect to a MySQL database with JSTL 1.0:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>JSTL MySQL</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <c:catch var="e">
    <sql:setDataSource var="datasource" url="jdbc:mysql://Your_Server_Name_Here/You_Schema_Here"
                           user="Your_Username_Here" password="Your_Password_Here"
                           driver="com.mysql.jdbc.Driver"/>
    <c:out value="datasource= ${datasource},  Class = ${driver.class}"/>
    <br />
    <br />
    <sql:query var="deejays" dataSource="${datasource}">SELECT * FROM Your_Table_Name_Here</sql:query>
    <table>
    <%-- Get the column names for the header of the table --%>
    <c:forEach var="columnName" items="${deejays.columnNames}"><th><c:out value="${columnName}"/></th></c:forEach>
    <tbody>
    <%-- Get the value of each column while iterating over rows --%>
    <c:forEach var="row" items="${deejays.rows}">
      <tr><c:forEach var="column" items="${row}">
            <td><c:out value="${column.value}"/></td>
          </c:forEach>
      </tr>
    </c:forEach>
    </tbody>
    </table>
    </c:catch>
    <br />
    <br />
    <c:if test="${e!=null}"><span class="error">Error</span>�
      <c:out value="${e}" />
    </c:if>
    </body>
    </html>And this thread might help you:
    http://forum.java.sun.com/thread.jspa?threadID=639471&tstart=44

  • JSP + MYSQL question: input form value into a SQL table

    Hello,
    I am writing some JSP code to read input information from a input form to write this information into a SQL field.
    My problems are:
    - how can i pass the input form information to other jsp file ? (like Getproperty of something like this)
    - how can i move the content of any input information into a variable ? I mean something like this:
    String a1;
    username.value.of.the.input.field.in.forum_jsp = a1.in.addmessage_jsp;and then:
    int rowsAffected = stmt.executeUpdate("INSERT INTO forummessages (messagecode, " +  " usercode, " + " messagedate,  " + " message) VALUES(6,3,06/07/2007,'" + a1 + "')");------
    The SQL table looks like this:
    stmt.executeUpdate("CREATE TABLE forummessages (messagecode int AUTO_INCREMENT PRIMARY KEY, usercode int, messagedate date, message char(255) not null)");My codes are:
    forum.jsp - this one should pass the input information to addmessage.jsp
    <%@ page contentType="text/html; charset=iso-8859-2" %>
    <%@ page import="java.sql.*" %>
    <%
    Connection con = null;
    Statement stmt = null;
    try {
      Class.forName("com.mysql.jdbc.Driver");
      String url =  "jdbc:mysql://localhost:3306/mysql";
      con =  DriverManager.getConnection(url,"root", "");
      stmt = con.createStatement();
      String sql = "SELECT * FROM forummessages,users,bmwecode WHERE (forummessages.usercode=users.usercode) AND (users.bmwcode=bmwecode.bmwcode)";
      ResultSet rs = stmt.executeQuery(sql);
    %>
    <html>
    <head>
    <title>JSP + MYSQL Teszt</title>
    </head>
    <body>
    <a href="forum.jsp">Forum / Uj hozzaszolas</a>
    <a href="userlist.jsp">Felhasznalok kilistazasa</a>
    <a href="adduser.jsp">Felhasznalo hozzadasa</a>
    <a href="deletemessage.jsp">Hozzaszolas torlese</a>
    <br><br>
    <form action="addmessage.jsp" method=post">
    Felhasznalo:
    <input type="text" name="username">
    <br><br>
    Hozzaszolas:
    <input type="text" name="message">
    <br><br>
    <input type="submit" value="Uj hozzaszolas">
    <br><br>
    <table border="0">
    <tr>
    <th>messagecode</th>
    <th>user</th>
    <th>car type</th>
    <th>message</th>
    </tr>
    <%
      while(rs.next()){
    %>
    <tr>
    <td><%=rs.getInt("messagecode") %></td>
    <td><%=rs.getString("username") %></td>
    <td><%=rs.getString("bmwtype") %></td>
    <td><%=rs.getString("message") %></td>
    </tr>
    <%
      } // end while
    %>
    </table>
    </body>
    </html>
    <%
    } catch (Exception e) {
      out.println("<font color=red><h3>Error:</h3></font>" + e);
      e.printStackTrace();
    } finally {
      try {
        if (stmt!=null) {
          stmt.close();
        if (con!=null) {
          con.close();
      } catch (Exception e) {
        e.printStackTrace();
    %> ----
    addmessage.jsp
    <%@ page contentType="text/html; charset=iso-8859-2" %>
    <%@ page import="java.sql.*" %>
    <%
    Connection con = null;
    Statement stmt = null;
    try {
      Class.forName("com.mysql.jdbc.Driver");
      String url =  "jdbc:mysql://localhost:3306/mysql";
      con =  DriverManager.getConnection(url,"root", "");
      stmt = con.createStatement();
    int rowsAffected = stmt.executeUpdate("INSERT INTO forummessages (messagecode, " +  " usercode, " + " messagedate,  " + " message) VALUES(6,3,06/07/2007,'" + a1 + "')");
    } catch (Exception e) {
      out.println("<font color=red><h3>Hiba:</h3></font>" + e);
      e.printStackTrace();
    } finally {
      try {
        if (stmt!=null) {
          stmt.close();
        if (con!=null) {
          con.close();
      } catch (Exception e) {
        e.printStackTrace();
    %>
    <a href="forum.jsp">Forum / Uj hozzaszolas</a>
    <a href="userlist.jsp">Felhasznalok kilistazasa</a>
    <a href="adduser.jsp">Felhasznalo hozzadasa</a>
    <a href="deletemessage.jsp">Hozzaszolas torlese</a>
    <br><br>---
    Thank you for your help in advance.

    SELECT DISTINCT
    hou.name
    ,poh.segment1 po_num
    ,pol.line_num po_line_num
    ,poh.currency_code
    --,trunc(poh.creation_date) po_creation_date
    ,pol.cancel_flag
    ,msi.segment1 item_num
    ,pol.unit_price
    ,round(cost.item_cost,5)
    ,round((&p_rate * pol.unit_price),5) "CONVERSION"
    ,(cost.item_cost - round((&p_rate * pol.unit_price),5)) difference
    ,pov.vendor_name
    FROM
    po.po_headers_all poh
    ,po.po_lines_all pol
    ,po.po_vendors pov
    ,hr.hr_all_organization_units hou
    ,inv.mtl_system_items_b msi
    ,bom.cst_item_costs cost
    WHERE
    poh.po_header_id = pol.po_header_id
    and pov.vendor_id = poh.vendor_id
    and poh.org_id = hou.organization_id
    and hou.organization_id = :p_operating_unit
    and poh.currency_code = :p_currency
    and poh.creation_date between :po_creation_date_from and :po_creation_date_to
    and poh.type_lookup_code = 'BLANKET'
    and msi.inventory_item_id = pol.item_id
    and cost.INVENTORY_ITEM_ID = pol.ITEM_ID
    --and (cost.item_cost - pol.unit_price) <> 0
    and (cost.item_cost - round((&p_rate * pol.unit_price),5)) <> 0
    and cost.organization_id = 1
    and msi.organization_id = 1
    and cost.cost_type_id = 3 --- Pending cost type
    and nvl(upper (pol.closed_code),'OPEN') not in('CANCELLED', 'CLOSED', 'FINALLY CLOSED', 'REJECTED')
    and nvl(upper (poh.closed_code),'OPEN') not in('CANCELLED', 'CLOSED', 'FINALLY CLOSED', 'REJECTED')
    and nvl(pol.cancel_flag, 'N') = 'N'
    and &p_rate user parameter
    I want this p_rate to be passed as a user parameter.

  • JSP - MYSQL HELP

    HI,
    Im trying to create a JSP which connects to a mysql database.
    I have downloaded all the connectivity drivers and dont know what to do from this stage.
    I have heard people talking about tomcat and apache but was wondering if i need them?
    Im new to all this connectivity bit so this is why i need help!!
    If anyone has any good links to some good jsp/mysql tutorials, please share!!!
    Thanks a lot

    You need a servlet/JSP engine, to start. You can't write or deploy a JSP without a servlet/JSP engine. Apache Tomcat is a good one to start with. It's free and robust:
    http://jakarta.apache.org/tomcat
    Here's a tutorial to get you started with servlets/JSP:
    http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
    Do a Google search or look at the Sun tutorials if you want more. - MOD

  • JSP MYSQL ERROR moving in resultset

    Hi I am new to jsp & mysql .
    I am trying to fetch data in a multiple select list box in my jsp page from a table in mysql . It fetches the first value and then exception is generated as no data found while there is data in the table . The same data in the table is fetched when i fetch in a dynamic table . I observed that i am having problems in fetching data only in list box . Please help me. It is a part of my project.
    Thanks

    Hi
    The code was generated my macromedia dreamweaver but still i'll writing it below:
    <select name="select" size="1" multiple>
    <%
    while (Recordset1_hasData) {
    %>
    <option value="<%=((Recordset1.getObject("overridetype")!=null)?Recordset1.getObject("overridetype"):"")%>"><%=((Recordset1.getObject("overridetype")!=null)?Recordset1.getObject("overridetype"):"")%></option>
    <%
    Recordset1_hasData = Recordset1.next();
    Recordset1.close();
    Recordset1 = StatementRecordset1.executeQuery();
    Recordset1_hasData = Recordset1.next();
    Recordset1_isEmpty = !Recordset1_hasData;
    %>
    </select>

  • JSP/MYSQL Hosting

    Hey all,
    Im looking to host a JSP/MYSQL site. Please tell me a hosting provider. also are there any providers in India that you know of . would really help if tis the same country.
    after looking through a lot of sites i have shortlisted.
    http://www.eatj.com and http://4java.ca tell me if there is anything in the same budget range. Are there anybody who is availing these services. please give your comments on the same
    Thanks
    Ritesh

    google myjavaserver
    it's free, but slow and space limited...

  • Setup mySQL and access the same from jsp

    Hi,
    I have installed the MySQL in local desktop in d: drive. As per the documentation, have created my.cnf file to point sql directory in d drive.
    Now I dont know how to proceed further. I need to see if MySQL installation is fine, create table and access the data in jsp page. Please advice.
    Thanks in advance.

    For MySQL help try a MySQL forum.
    For connecting to the database, use JDBC. You can get the MySQL JDBC driver from www.mysql.com.
    From there just follow standard java database connection setup.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • [b][u]JSP/mySQL CREATE DATABASE problem[/u][/b]

    I am trying to create a mySQL DB through JSP program (query).
    The Query :
    stmt.executeUpdate("CREATE DATABASE employee;");
    is not working. PLEASE HELP ME.................
    The program is as follows.
    try
    Connection con =null;
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bedrock","Dude","");
    System.out.println("Connection Established");
    try {
    System.out.println("Entered Try Block");
    stmt=con.createStatement();
    stmt.executeUpdate("CREATE DATABASE employee;");
    System.out.println("Query Executed");
    catch(Exception e){ 
    System.out.println("Entered Catch Block");
    System.out.println("Query Skipped");
    catch (SQLException ex)
    while (ex != null){
    System.out.println("sql exception"+ex);
    ex = ex.getNextException ();
    Message was edited by:
    sam_john

    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bedrock","Dude","");
    Access denied for user: '[email protected]' (Using password: NO)
    You must provide a password for your connection.
    Your code should have been as follows:
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bedrock","Dude","YOUR_PASSWORD_HERE");Anyway, to create a database or a table in a db server like MySQL, you must have the good privileges to.
    Go to <MySQL_INSTALL_DIR>/Docs/ directory, you'll find there the MySQL manual.chm. Take a look at the the Tutorial section.
    In order to know how to use jdbc Connector/J, take a look at the documentation shipped with: /mysql-connector-java-X.X.X/docs/connector-j.html
    Here a typical code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    public class TestMySQL {
         public static void main(String[] args) {
              Connection con = null;
              Statement stmt = null;
              try {
                   Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                   con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bedrock", "Dude", "YOUR_PASSWORD_HERE");////// put the right password here
                   System.out.println("Connection Established");
                   System.out.println("Entered Try Block");
                   stmt = con.createStatement();
                   stmt.executeUpdate("CREATE DATABASE employee");
                   System.out.println("Query Executed");
              } catch (Exception e) {
                   e.printStackTrace();
              } finally {
                   if (stmt != null) {
                        try {
                             stmt.close();
                        } catch (Exception e) {
                   if (con != null) {
                        try {
                             con.close();
                        } catch (Exception e) {
    }Hope That Helps

  • JDBC/JSP/MySQL Code works from my local machine, but not on server

    Hi there!
    I've been struggling with this problem for a while.
    I have a database from which I need to read and display some data on a browser. (The database is set up for remote access).
    I'm using the following JSP/JDBC code to do that.
    Class.forName ("com.mysql.jdbc.Driver").newInstance();
    out.println("<BR> Connecting to DB...Pls. Wait <BR>");
    Connection con = DriverManager.getConnection("url","user","pwd");
    if(con.isClosed())
    out.println("<BR><BR><BR>" +"Could NOT connect to MySQL Database...");
    else out.println("<BR> CONNECTED !!! <BR>");
    Statement stmt = con.createStatement();
    results = stmt.executeQuery("SELECT * FROM TableName" );
    When I run this of my local machine, it works fine. But when I upload it to a server, it doesn't run through. I dont get either the connected or not connected message.
    I tried this piece of code that I found online to check the driver.
    /*Driver d = (Driver)Class.forName("com.mysql.jdbc.Driver").newInstance();
    out.println("<BR>Got a driver instance. ");
    if (d.acceptsURL(url)) out.println("<BR>The driver does accept my URL");
    else out.println("<BR>The driver doesn't like the URL I'm trying"); */
    I ran it off the server and it worked. I got the outputs --Got a driver instance and The driver does accept my URL
    I'm unable to figure out why this code can be run locally from my machine, but not from a different location. The database is NOT on my machine.
    Any inouts will be really appreciated.
    I'm using an Apache Tomcat container and the database is MySQL.

    Just wanted to mention
    The database is on another (3rd) machine.
    So I have
    1. My local machine
    2. Database hosted on a 2nd machine
    3. Place I'm moving my code to (its basically a hosting account provided by an external company)
    I can access the database from my local machine. However, when I move the code over to another machine, it doesn't work.

  • Why doesn't doFilter work was expected when a .jsp page is accessed?

    I'm hoping an expert could point me in the right direction or tell me
              if this is a bug in WebLogic.
              My environment is WebLogic 6.1 (service pack 4), on Windows 2000.
              I need to capture all the response data that comes back from the
              servlet. So, I have a simple filter that wraps the response object,
              and sends the wrapped object into filterChain.doFilter() method.
              I've set up the web.xml so that any servlet access should trigger my
              filter (the <url-pattern> is /*). I've also configured a sample
              web-app called TEST to serve .html/.jsp pages.
              When the browser makes a .html request, everything works as expected.
              After the filterChain.doFilter(), I can take a look at the wrapped
              response object and print the contents of the response.
              However, when I access a .jsp page as part of form data submit, the
              output stream of my wrapper is empty after the filterChain.doFilter()
              completes.
              If I don't wrap the response, then everything seems to work fine. The
              .jsp gets interpreted properly by the servlet container, I can see the
              result page in the browser just fine.
              By inserting debug statements, I can see that if I wrap the responses,
              for a .html request, under the covers, wrapper's getOutputStream()
              gets called. But for a .jsp request, under the covers, wrapper's
              getWriter() gets called. I don't know how significant this is, but
              this is the only difference I see!
              If I don't wrap the response, I am not sure how to get at the response
              data. All I need to do is to take certain actions depending on the
              response. That is why I'm using a wrapper to get at the response data.
              In the JRun AppServer, the code just works fine.
              I've enclosed the source code & the output that demonstrates the
              problem.
              What am I doing wrong? Or, is this a bug in WebLogic? If this is a
              bug, is there a patch available?
              Thanks,
              --Sridhar
              // HeaderFilter.java
              // This is the filter that gets invoked through the web.xml
              configuration
              import javax.servlet.*;
              import javax.servlet.http.*;
              import java.io.*;
              import java.util.*;
              public class HeaderFilter implements Filter {
              public FilterConfig filterConfig;
              public void destroy() {
                        this.filterConfig = null;
                   public void init(FilterConfig filterConfig) {
                        this.filterConfig = filterConfig;
              public FilterConfig getFilterConfig() {
              return filterConfig;
              public void setFilterConfig(FilterConfig filterConfig) {
              this.filterConfig = filterConfig;
              public void doFilter(ServletRequest req, ServletResponse resp,
              FilterChain chain)
              throws java.io.IOException, javax.servlet.ServletException {
              ServletContext context = filterConfig.getServletContext();
              HttpServletResponse response = (HttpServletResponse)resp;
              TestResponseWrapper wrapper = new
              TestResponseWrapper(response);
              chain.doFilter(req, wrapper);
              OutputStream out = resp.getOutputStream();
              System.out.println("The content length is :" +
              wrapper.getContentLength());
              if ("text/html".equals(wrapper.getContentType())) {
              byte[] data = wrapper.getData();
              System.out.println("TEXT RESPONSE, length is " +
              data.length);
              System.out.println(new String(data));
              out.write(data);
              // out.close();
              // TestResponseWrapper.java
              // This class wraps the response object so that you could take a look
              at
              // the response contents after the filterConfig.doFilter() method
              import javax.servlet.ServletOutputStream;
              import javax.servlet.http.HttpServletResponse;
              import javax.servlet.http.HttpServletResponseWrapper;
              import java.io.ByteArrayOutputStream;
              import java.io.PrintWriter;
              public class TestResponseWrapper extends HttpServletResponseWrapper{
              private ByteArrayOutputStream output;
              private int contentLength;
              private String contentType;
              public TestResponseWrapper(HttpServletResponse response) {       
              super(response);
              output = new ByteArrayOutputStream();
              public ServletOutputStream getOutputStream() {    
              System.out.println("****** getOutputStream() called *******");
              return new FilterServletOutputStream(output);
              public byte[] getData() {
              return output.toByteArray();
              public PrintWriter getWriter() {   
              System.out.println("****** getWriter() called *******");
              return new PrintWriter(getOutputStream(), false);
              public void setContentType(String type) {       
              System.out.println("**** Wrapper setContentType called ****");
              this.contentType = type;
              super.setContentType(type);
              public String getContentType() {       
              return this.contentType;
              public int getContentLength() {    
              return contentLength;
              public void setContentLength(int length) {       
              System.out.println("**** Wrapper setContentLength called
              this.contentLength=length;
              super.setContentLength(length);
              // FilterServletOutputStream.java
              // This class is used by the wrapper for getOutputStream() method
              // to return a ServletOutputStream object.
              import javax.servlet.ServletOutputStream;
              import java.io.DataOutputStream;
              import java.io.IOException;
              import java.io.OutputStream;
              import java.io.*;
              public class FilterServletOutputStream extends ServletOutputStream {
              private DataOutputStream stream;
              public FilterServletOutputStream(OutputStream output) {       
              stream = new DataOutputStream(output);
              public void write(int b) throws IOException {       
              stream.write(b);
              public void write(byte[] b) throws IOException {       
              stream.write(b);
              public void write(byte[] b, int off, int len) throws IOException {
              stream.write(b, off, len);
              // test.html
              <html>
              <head>
              <meta http-equiv="Content-Type"
              content="text/html; charset=iso-8859-1">
              <title> Web Posting Information </title>
              </head>
              <body>
              <form name="myform" method="POST" action="resource.jsp">
              <input type="TEXT" name="input"></input>
              <br>
              <input type="SUBMIT" value="done"></input>
              </form>
              </body>
              </html>
              // resource.jsp
              // This gets referenced by the test.html file
              <HTML><BODY>
              <head>
              <title>JRun Programming Techniques</title>
              <meta http-equiv="Content-Type" content="text/html;
              charset=iso-8859-1">
              </head>
              <body>
              <H3>Secure Resource Page</H3>
              <p>This is a secure page.</p>
              <BR><B>User: </B>
              <%
              //     out.write(request.getParameter("input"));
              %>
              </BODY></HTML>
              // HERE IS THE OUTPUT
              // HERE IS WHAT I SEE WHEN I ACCESS
              // http://localhost:7001/TEST/test.html
              **** Wrapper setContentType called ****
              **** Wrapper setContentLength called ****
              ****** getOutputStream() called *******
              The content length is :331
              TEXT RESPONSE, length is 331
              <html>
              <head>
              <meta http-equiv="Content-Type"
              content="text/html; charset=iso-8859-1">
              <title> Web Posting Information </title>
              </head>
              <body>
              <form name="myform" method="POST" action="resource.jsp">
              <input type="TEXT" name="input"></input>
              <br>
              <input type="SUBMIT" value="done"></input>
              </form>
              </body>
              </html>
              // HERE IS WHAT I SEE WHEN I enter some value in the "input" field
              // of the form, and click on the "submit" button.
              // Why isn't setContentLength() getting called on the wrapper?
              // It appears as if the wrapper's output stream isn't getting used
              // at all!!!
              **** Wrapper setContentType called ****
              ****** getWriter() called *******
              ****** getOutputStream() called *******
              The content length is :0
              TEXT RESPONSE, length is 0
              

    If someone else runs into this, here is how I solved the problem -
              If you create a PrintWriter object with the autoflush option, it
              doesn't flush the underlying buffer till you call println on it. I
              looked through the generated code for the servlet, and it was doing a
              JSPWriter.print() to output information.
              So, I changed the ResponseWrapper to keep a handle to the PrintWriter
              object, and then flush it in the filter, and that works.
              Why the same code behaves differently in JRun & Weblogic, I'm not sure
              --Sridhar
              

  • I have setup JSP & MySQL but how can i Connect it to eche other ?

    I feel sory by asking this qustion but i tried very enough
    100 mile start from 1 mile ^_^
    I have tested JSP files by http://localhost:8080/test.jsp
    and it works very will
    also i have already installd MySQL and i can create databases and tables by http://localhost/phpMyAdmin
    so what i have to do else to connect JSP to MySQL ? , ( if nothing )
    how can i test that MySQL Connected with JSP, so that i can display data from database ?
    Best Regards
    JMalik

    create a java bean, which is just similar to a java class and put the database connection there so you wouldn't have to include that code in all you jsps everytime you connect to the database
    this is for DbConnection.java
    package connection;
    import java.sql.*;
    import java.io.*;
    public class DBConnection
         private Connection con;
         public DBConnection()
              try
                  Class.forName("com.mysql.jdbc.Driver");
                  con = DriverManager.getConnection("jdbc:mysql://localhost/yourfolder?user=yourusername&password=yourpassword");
            catch (Exception e)
                 e.printStackTrace();
         public Connection getConnection()
              return con;
         public void close()
              try
                   con.close();
              catch(Exception e)
                   e.printStackTrace();
    }in another bean/class which connects to your database,
    say for example this is SelectUsers.java
    public String[] selectActiveUsers(int id) throws Exception, SQLException
         try
                   con = new DBConnection().getConnection();
                   Statement stmt = con.createStatement();
                   String ins = "<your select statement>";     
                            stmt.executeUpdate(ins);
                            con.close();
                   stmt.close();
             catch (SQLException se)
                    System.out.println("SQL Exception: " + se.getMessage() + "not connected");
                    se.printStackTrace(System.out);
         }and in your jsp, instantiate the class
    users.jsp
    SelectUsers su = new SelectUsers();
    String[] users = su.selectActiveUsers(1);got it?
    Message was edited by:
    shuini

  • JSP Error: While accessing the 11.5.10.2 Login Page

    Dear All,
    While trying to access the Login Page of 11.5.10.2 version for the first time, after a fresh installation, I am getting the following Error:
    JSP Error:
    Request URI:/OA_HTML/AppsLocalLogin.jsp
    Exception:
    java.lang.NoSuchMethodError: oracle.apps.fnd.sso.Utils.setRequestCharacterEncoding(Ljavax/servlet/http/HttpServletRequest;)V
    Please advice Whether anynthing wrong with the installation
    Thanks..,

    Hi,
    many thanks for the response....
    Please find the log file details as follows:
    $APACHE_TOP/Apache/Jserv/logs
    I could find a file called: mod_jserv.log and below shown is the content of the file:
    [23/03/2008 11:49:34:305] (EMERGENCY) ajp12: can not connect to host 192.168.0.33:17000
    [23/03/2008 11:49:34:328] (EMERGENCY) ajp12: function connection fail
    [23/03/2008 11:49:35:332] (EMERGENCY) ajp12: can not connect to host 192.168.0.33:16000
    [23/03/2008 11:49:35:332] (EMERGENCY) ajp12: function connection fail
    [23/03/2008 11:49:36:336] (EMERGENCY) ajp12: can not connect to host 192.168.0.33:19000
    [23/03/2008 11:49:36:336] (EMERGENCY) ajp12: function connection fail
    $APACHE_TOP/Apache/Jserv/logs/jvm
    File1: OACoreGroup.0.stdout
    ApacheJServ/1.1
    Starting Self-Service Mobile Framework v1.0.8.4 initialization
    Servlet Initialized
    ApacheJServ/1.1.2
    Starting Self-Service Mobile Framework v1.0.8.4 initialization
    0.000: [GC 34944K->1794K(126720K), 0.0622710 secs]
    3.707: [Full GC 16414K->1951K(126720K), 0.1113560 secs]
    Servlet Initialized
    1799.126: [GC 37023K->2432K(126848K), 0.0212320 secs]
    3866.431: [GC 37504K->2449K(126848K), 0.0046790 secs]
    5929.879: [GC 37521K->2449K(126848K), 0.0067740 secs]
    7997.123: [GC 37521K->2449K(126848K), 0.0057680 secs]
    9406.379: [GC 37521K->3421K(126848K), 0.0273190 secs]
    ApacheJServ/1.1.2
    Starting Self-Service Mobile Framework v1.0.8.4 initialization
    0.000: [GC 34944K->1802K(126720K), 0.0434050 secs]
    3.248: [Full GC 13181K->1934K(126720K), 0.1367460 secs]
    Servlet Initialized
    9.498: [Full GC 19627K->2914K(126848K), 0.1657290 secs]
    22.202: [GC 37986K->14162K(126848K), 0.1693410 secs]
    30.267: [Full GC 26205K->15086K(126848K), 0.2766730 secs]
    105.147: [GC 50157K->16481K(126848K), 0.0409380 secs]
    428.416: [GC 51553K->17758K(126848K), 0.0368180 secs]
    868.359: [GC 52830K->18783K(126848K), 0.0543650 secs]
    1036.996: [GC 53853K->20868K(126848K), 0.0410590 secs]
    1680.842: [GC 55940K->21729K(126848K), 0.0395180 secs]
    2225.097: [GC 56801K->22640K(126848K), 0.0286630 secs]
    2226.562: [GC 57712K->22610K(126848K), 0.0344330 secs]
    2230.827: [GC 57682K->23727K(126848K), 0.0224470 secs]
    2233.623: [GC 58799K->25684K(126848K), 0.0639170 secs]
    3002.680: [GC 60756K->29063K(126848K), 0.0522580 secs]
    3533.140: [GC 64129K->30333K(126848K), 0.0582700 secs]
    4078.031: [GC 65405K->30808K(126848K), 0.0151680 secs]
    4101.383: [Full GC[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor9]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor6]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor4]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor3]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor1]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor8]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor5]
    [Unloading class sun.reflect.GeneratedSerializationConstructorAccessor7]
    File2: DiscoGroup.0.stdout
    ApacheJServ/1.1
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    Discoverer Model - 4.1.46.08.00
    WARNING: Attempting to use HTTP Firewall Proxy Server
    due to security restrictions: org.omg.CORBA.INTERNAL: Can not find GateKeeper: exception ReqFailure{} minor code: 0 completed: No
    ApacheJServ/1.1.2
    0.000: [GC 34944K->605K(126720K), 0.0160370 secs]
    3108.991: [GC 35549K->627K(126720K), 0.0076150 secs]
    6231.719: [GC 35571K->628K(126720K), 0.0097730 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->605K(126720K), 0.0175620 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->605K(126720K), 0.0114060 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->594K(126720K), 0.0099880 secs]
    3104.899: [GC 35538K->616K(126720K), 0.0054030 secs]
    6212.468: [GC 35560K->616K(126720K), 0.0043100 secs]
    9320.398: [GC 35560K->616K(126720K), 0.0043180 secs]
    12431.724: [GC 35560K->616K(126720K), 0.0042310 secs]
    15540.350: [GC 35560K->616K(126720K), 0.0050770 secs]
    18648.742: [GC 35560K->616K(126720K), 0.0049940 secs]
    File 3: XmlSvcsGrp.0.stdout
    ApacheJServ/1.1
    ApacheJServ/1.1.2
    0.000: [GC 34944K->992K(126720K), 0.0222780 secs]
    1331.380: [GC 35936K->1596K(126720K), 0.0252860 secs]
    2978.434: [GC 36540K->1572K(126720K), 0.0155030 secs]
    4561.042: [GC 36509K->2146K(126720K), 0.0124670 secs]
    6159.901: [GC 37090K->1568K(126720K), 0.0162710 secs]
    7801.433: [GC 36488K->1600K(126720K), 0.0096090 secs]
    9361.497: [GC 36532K->2144K(126720K), 0.0111690 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->1516K(126720K), 0.0335350 secs]
    1637.366: [GC 36460K->1617K(126720K), 0.0119330 secs]
    3201.033: [GC 36548K->2141K(126720K), 0.0153640 secs]
    4820.604: [GC 37085K->1567K(126720K), 0.0147900 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->1516K(126720K), 0.0219900 secs]
    1637.286: [GC 36460K->1617K(126720K), 0.0118590 secs]
    3202.661: [GC 36548K->2142K(126720K), 0.0135660 secs]
    ApacheJServ/1.1.2
    0.000: [GC 34944K->923K(126720K), 0.0378160 secs]
    465.724: [GC 35867K->958K(126720K), 0.0107050 secs]
    2049.456: [GC 35881K->1536K(126720K), 0.0106250 secs]
    3632.469: [GC 36480K->991K(126720K), 0.0070540 secs]
    5276.173: [GC 35935K->993K(126720K), 0.0069840 secs]
    6849.801: [GC 35912K->1567K(126720K), 0.0098510 secs]
    8450.902: [GC 36511K->990K(126720K), 0.0112260 secs]
    10089.975: [GC 35909K->990K(126720K), 0.0068660 secs]
    11650.057: [GC 35921K->1566K(126720K), 0.0084910 secs]
    13269.947: [GC 36510K->991K(126720K), 0.0068470 secs]
    14890.263: [GC 35910K->1213K(126720K), 0.0074270 secs]
    16452.170: [GC 36157K->987K(126720K), 0.0068140 secs]
    18094.799: [GC 35931K->993K(126720K), 0.0069330 secs]
    19690.498: [GC 35912K->1468K(126720K), 0.0081220 secs]
    21269.320: [GC 36412K->988K(126720K), 0.0070610 secs]
    22908.334: [GC 35932K->993K(126720K), 0.0068100 secs]
    24490.848: [GC 35910K->1567K(126720K), 0.0083790 secs]
    26082.852: [GC 36511K->989K(126720K), 0.0103980 secs]
    27721.116: [GC 35933K->993K(126720K), 0.0068200 secs]
    ApacheJServ/1.1.2
    ApacheJServ/1.1.2
    0.000: [GC 34944K->937K(126720K), 0.0231740 secs]

  • JSP & MySQL

    Hi!
    I am Pranay. I want to connect my JSP with MySQL. Will you please help me? I want the detail-code and pre-coding instructions.....
    General Informations:
    1. JDK 1.5.0
    2. Apache Tomcat 4.1
    3. MySQL Server 5.0
    4. MySQL Connector/J 5.0.4
    5. JAVA_CLASSPATH
    C:\Program Files\Java\jdk1.5.0\bin
    6. CLASSPATH
    C:\Program Files\mysql-connector-java-5.0.4
    Plz consider that I have a table in my MySQL database name tab1 which has fields: name,roll,date_of_birth.
    Thanx...

    The error you are getting looks like a network (socket) error rather than a JDBC or MySQL problem. The error indicates that a connection cannot be negotiated from Tomcat to MySQL. Are you sure MySQL is running on your laptop? Try to telnet to the MySQL port:
    (on windows, from the command prompt)
    C:\>telnet localhost 3306
    If this connects (the command promt screen should clear) then the problem is elsewhere, but my bet is you won't be able to connect this way either.
    If you cannot connect using telnet:
    1. Verify that MySQL is running on your laptop
    2. Verify that it's listening on port 3306
    3. Check that you don't have any local firewall apps blocking this traffic
    4. Verify that you don't have any manual host configurations which mean "localhost" points somewhere else (unlikely)
    If you CAN connect using telnet:
    1. Verify that your connection string is correct as per the MySQL JDBC Driver documentation
    2. Verify that your authentication credentials are correct (don't think it's this)
    Now... for a few supplimentary notes:
    You appear to be using the connection.isClosed() method to test whether you have a connection. This serves no purpose in the context you are using it as it's just a boolean which gets set when close() is called on the connection. ergo you could quite easily have a broken connection which returns "false" on an isClosed() call.
    Also, it is (strictly speaking) considered a better architecture to limit your JSP code to "display logic" only. This means it is usually void of any business logic or database-related code. You should really look at something like the MVC architecture (model-view-controller). This will save you a lot of headaches in the long run. If nothing else, debugging JSPs can be a real nightmare. I recommend you look at the Struts project (Apache Jakarta). It has become the defacto standard implementation of MVC.
    Good luck :)

  • How to connect JSp to ms-access?

    hello Everybody,
    I have a database created in MS-Access. Database name "est". Table name "Customer".
    I have created System DSN by name "est" for Access database.
    This Customer table contains user-id and password.
    Now, from front end, using JSP, i have created a login page. USer will enter their id and password....
    in the following code, i am trying to access this table IF there is any record with user entered cid and password, count's value will be 1 else 0.
    <%@ page language="java"%>
    <%@ page  import="java.text.*,java.sql.*,java.util.*,javax.servlet.*,javax.servlet.http.*" %>
    <%
    //creating a Connection, to connect to the database
              try {
                   String uid = request.getParameter("Lng").trim();
                   String pwd=request.getParameter("pwrd").trim();
                   String query = new String();
                   ResultSet rs = null;
                   Connection con = null;
                   //initializing the JDBC-ODBC bridge driver
                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                  //open a connection to the database
                   con = DriverManager.getConnection("jdbc:odbc:acc",uid,pwd);
                  //execute the query
               Statement stmt = con.createStatement();
                 query="select count(*) as count1 from est.Customers where cid='"+uid+"'password='"+pwd+"'";
                   System.out.println(query);
                   rs=stmt.executeQuery(query);
                   System.out.println("creating the connection is success");
                   session.setAttribute("uid",uid);
                   session.setAttribute("pwd",pwd);
                   session.setAttribute("connect","yes");
                   response.sendRedirect("");
                   } catch(Exception e)
                   System.out.println("Error in creating the connection"+e);
                    out.println("Error in creating the connection");
                    response.sendRedirect("login1.jsp");
         %>
         <html>
                             <head><title>Validation Screen</title>
                             </head>
                             <body>
                             <FONT STYLE=Courier: color=RED  SIZE=5>
                             <p align=center><b><font SIZE=4 color=brown face=" ">LOGGEDINN SUCCESSFULLY</font></b>
                             </body>     
                             </html>
                   But, i am getting "No data found error". Can anyone please help me in this regards, please?
    Regards,
    Thanks in advance for your time and help
    Ashvini

    i have to connect jsp to sql server
    how can i do this::::::::::::
    actually,i have written the code in textpad in java file which is working fine
    but when i apply the same code in jsp file in weblogic , it is giving error in line
    "DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());"
    weblogic is not recognising "com.microsoft" package in this line
    but i haven't done anything special in textpad
    looking forward for reply
    My code written in textpad:::::::::::
    import java.sql.*;
    * Microsoft SQL Server JDBC test program
    public class TestCalculator {
    public TestCalculator() throws Exception {
    /******************* Get connection ************************************/
    DriverManager.registerDriver(new
    com.microsoft.jdbc.sqlserver.SQLServerDriver());
    Connection connection = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://192.9.203.153:1433","attend","attend");
    if (connection != null) {
    System.out.println();
    System.out.println("Successfully connected");
    System.out.println();
    System.out.println("HELLO");
    Statement stmt;
    try
    stmt = connection.createStatement();
                   ResultSet resultSet = stmt.executeQuery("Select * from tblcode where empcode='2923'");
                        while (resultSet.next()){
                        System.out.println(resultSet.getString(1) + " " + resultSet.getString(2)+" "+resultSet.getString(3));
                        resultSet.close();
    //stmt = conn.createStatement();
    //stmt.executeUpdate("insert into EmployeeData " +
    //"values('name', 'salary','joiningDate','empId','leavingDate')");
    /*stmt.executeUpdate("insert into cust_profile " +
    "values('name2', 'add2','city2','state2','country2')");
    stmt.executeUpdate("insert into cust_profile " +
    "values('name3', 'add3','city3','state3','country3')"); */
    stmt.close();
    connection.close();
    catch (Exception e)
    e.printStackTrace();
    }//TestCalculator
    public static void main (String args[]) throws Exception {
    TestCalculator test = new TestCalculator();
    }//End of class

  • In a JSP how can access an XML where the XML is present in JAR file in the

    All,
    The Requirement is as below,
    I have a JSP LaunchMe.jsp, and I have a jar utils.jar. both are present in my deployable war file.
    And I have an XML Details.XML present in the utils.jar file.
    Here I want to access Details.xml in the LaunchMe.jsp.
    Can any one please let me know how can I do this.
    Thanks,
    Subramanyam V

    Yes. You have to understand that to read a FILE (one that is seen as a file by your OS), you probably use a FileInputStream, which is a special case of InputStream. When the 'file' is not a FILE anymore, but an entry in a jar (the OS does not see it, only utilities like WinZip or jar see it), you cannot use a FileInputStream, but some other InputStream. Which one? The one returned by getResourceAsStream(), whatever this is (you don't really care). And all the rest will nicely fall into place.

Maybe you are looking for

  • 2011 i5 Mac mini no startup screen, but computer starts fine...

    I just got a new Mac mini MC815 i5 2.3 Ghz a few monrhs ago, and I added 8 GB of RAM and a 750GB 7200 HD then did a fresh install of Lion 10.7.4 a few weeks ago. When I use the Mac mini on any normal 24" Acer PC LCD via HDMI to DVI adaptor or Thunder

  • Question on differences in development of webdynpro in ce 71 to nw04s

    Hi All A webdynpro developed in NWDS 7.0 SP15 which runs on NW04S SP15 ,will this be able to run in CE 7.1 without any changes.Can I import the project file (of webdynpro developed in NWDS 7.0 sp15 )to CE7.1 SR5 and deploy it and run in CE7.1 without

  • Add file to ZIP in Java program

    Hi all, I already found a lot of documentations of how to ZIP files in Java with the java.util.zip package, like: http://java.sun.com/developer/technicalArticles/Programming/compression/ This algorithm works fine when you always want to create a fres

  • Calling FLV's in xml data list

    Hi All, Total n00b here. I have been building for the first time using spry and this is what i'm trying to do. Have a thumbnail with description, plus some body text and then the flv video that goes with the story. I have had success with the html da

  • Recently purchased X1, Windows 7 update issues

    Hello everyone! I recently purchased the X1 and I love it so far. But I am having troubles with Windows update. I am able to download the updates. But whenever I go to restart my computer to complete the updating process, the "configuring Windows upd