How to establish a MYSQL Database connection in JSP page.

Hi People,
Tell me how to establish mysql database connection in JSP page.
Needed details on:
1) what are all the mysql drivers need to be included.
2) what is the syntax for establish a database connection

hi,
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.htmlsee down for mysql config with tomcat

Similar Messages

  • Sharing Portal database connection with JSP page

    Hi out there,
    I implemented a JSP page as a selection form to be integrated into Oracle Portal. This JSP page contains a 'dynamic' form which needs to send queries to the database also integrated in the Portal.
    For this I am currently using a JDBC connection but I would prefer to use the internal db connection of the Portal System.
    Explanation: The user has to log in to the Portal and after that can call the JSP form. To poulate some comboboxes within this form I need some data from the database and the user does have READING privileges on that database.
    Can anybody tell me how to use the user's login and password (or the established connection) to fetch the needed data from the database OTHER than with a jdbc connection?
    Thanx in advance!
    Cheers,
    Thomas

    sorry. not going to happen. you're running in a completely different environment when running Java on Portal. Portal is running in the database; your Java is running on the application server. your Java code must use JDBC to access any database resources, even if Portal related.
    it is essential that you implement a connection pool on the application server to optimize your database traffic. check out bitmechanic for a very good open source option.
    good luck,
    rich

  • Database connection to jsp page

    I have a data entry form in HTML and done validation in javascript.
    From that form the values entered by the user, is displayed on JSP page by method.
    <%=request.getParameter(" ")%
    MY problem is:
    i want that the values shown by the jsp page, is submitted or saved into database automatically, when i click submit button on the page.
    How can i do this.
    I have to use jdbc driver to make a connection for the database.
    plzz help me, as it is very urgent.
    my jsp page is as follow:
    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head>
    <title></title>
    <body>
    <%
    try {
    //Load the jdbc driver
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //Create a connection object
    Connection con=DriverManager.getConnection("jdbcdbc:jspsql","java","java");
    System.out.println("got connection");
    // Create a statement object and call its executeUpdate method to insert a record
    Statement s=con.createStatement();
    String sql = "INSERT INTO Gl_Mast VALUES ('1','ABHI','120','520')";
    s.executeUpdate(sql);
    // Step 4. Use the same Statement object to obtain a ResultSet object
    sql = "SELECT GL_CODE, GL_DESCR FROM Gl_Mast";
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    out.println(rs.getString(1) + " " + rs.getString(2) + "<br>");
    rs.close();
    s.close();
    con.close();
    catch (ClassNotFoundException e1) {
    // JDBC driver class not found, print error message to the console
    System.out.println(e1.toString());
    catch (SQLException e2) {
    // Exception when executing java.sql related commands, print error message to the console
    System.out.println(e2.toString());
    catch (Exception e3) {
    // other unexpected exception, print error message to the console
    System.out.println(e3.toString());
    %>
    <form name="display" ACTION="" >
    <table width="100%" border="3">
    <tr>
    <TD COLSPAN=5><center><h3><b><i>GL MASTER INFORMATION</i></b></h3></center></TD>
    </TR>
    <tr>
    <th>Code No.</th>
    <th>Description</th>
    <th>Dr. Amount</th>
    <th>Cr. Amount</th>
    <th>Type</th>
    </tr>
    <tr>
    <td> <%=request.getParameter("code")%></td>
    <td> <%=request.getParameter("Description")%></td>
    <td> <%=request.getParameter("DrAmount")%></td>
    <td> <%=request.getParameter("CrAmount")%> </td>
    <td> <%=request.getParameter("type")%></td>
    </tr>
    </table>
    <p>
    <INPUT TYPE="submit" VALUE="SAVE" >
    <INPUT TYPE="button" VALUE="BACK" onClick="history.go(-1)">
    </body>
    </html>
    thanx..
    abhijit

    X POST

  • Jsp JST MySQL - database connection

    Hello
    I am facing a database connection problem. I want to connect to mysql database fro a jsp page that uses JSTL taglibs.
    I am using Tomcat 5.x, JSTL 1.1. MySQL 5x
    I have copied jstl.jar, standard.jar and mysql driver in the \WEB-INF\lib dir of my application.
    If I connect to the database using scriptlet it works. But If I connect using the sql taglib, it gives me the error
    2008-01-22 14:20:12 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
    my jsp file is as follows
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <c:set var="firstName">request.getParameter("name")</c:set>;
    <%= request.getParameter("name") %>
    <sql:setDataSource
    var="myDS"
    scope="request"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/contact_db"
    user="root"
    password=""
    />
    <sql:query var="phone_book" dataSource="$(myDS)">
    Select last_name, home, cell, office from phone_book where first_name = ?
    <sql:param value="firstName"/>
    </sql:query>
    <HTML>

    hi thanks
    please let me know whats the better approach for getting an database connection if this is not recommended.
    after some modifications i am not getting the no suitable driver error. I also updated the code as per your comments. ...yet am not seeing any results.
    I have modified the file as follows.
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
    String firstName = request.getParameter("name");
    %>
    <%= firstName %>
    <sql:setDataSource
    var = "firstDS"
    scope="request"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/contact_db"
    user="root"
    password=""
    />
    <sql:query var="phone_book" dataSource="${firstDS}">
         Select * from phone_book where first_name = ?
         <sql:param value="${firstName}"/>
    </sql:query>
    <c:forEach var="phone_book" items="${user.rows}">
         <tr>
    <td><c:out value="${row.no}"/></td>
    <td><c:out value="${row.first_name}"/></td>
    <td><c:out value="${row.last_title}"/></td>
    <td><c:out value="${row.home}"/></td>
    <td><c:out value="${row.cell}"/></td>
    <td><c:out value="${row.office}"/></td>
    </tr>
    </c:forEach>
    <HTML>
    <BODY>
         Hello
    </BODY>
    </HTML>

  • BOE XI 3.1 Mysql database connection jar

    Hi All,
    I am new learner for BOE.I installed Business Object Enterpraise 12.0.
    I have created the report WebI rich client and saved in local path, and also some value insert into mysql database table.
    I need to know how its stored into mysql database.
    which jar file is used for creating the connection with mysql database .
    Thanks,
    Yousuf
    Edited by: yousufalam on Dec 31, 2010 12:40 PM

    The connection objects are store in the CI_APPOBJECTS repository table with SI_KIND='Metadata.DataConnection' . The connection properties are stored as property bags along with your objects.
    Unfortunately I have just found a reference that this kind of access in not fully supported though and you may have to use the Universe Designer SDK (COM based)
    Change password of Universe connection using Java SDK?
    Since you are working with the SDK it will make sense to post your questions here:
    Java SDK Application Development
    Regards,
    Stratos

  • When and How to close database connection in JSP?

    Hi there,
    I am using MySQL and JDBC 3.0, in my system, When and How to close database connection in JSP?
    Thanks in advance.
    Lonely Wolf
    <%@ page session="true" language="java" %>
    <jsp:include page="checkauthorization.jsp" />
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%--
    Execute query, with wildcard characters added to the
    parameter values used in the search criteria
    --%>
    <sql:query var="availablecomputerList" dataSource="jdbc/Bookingcomputer" scope="request">
    SELECT * FROM computer where status=0
    order by s_code
    </sql:query>
    <html>
    <head>
    <title>Search Result</title>
    </head>
    <body bgcolor="white">
    <center>
    <form action="checkin.jsp" method="post">
    <input type="submit" value="Back to Check-in Page">
    </form>
    <c:choose>
    <c:when test="${availablecomputerList.rowCount == 0}">
    Sorry, no available computer found.
    </c:when>
    <c:otherwise>
    The following available computers were found:
    <table border="1">
    <th>Computer</th>
    <th>Description</th>
    <th>Status</th>
    <c:forEach items="${availablecomputerList.rows}" var="row">
    <tr>
    <td><c:out value="${row.s_code}" /></td>
    <td><c:out value="${row.description}" /></td>
    <td><c:out value="${row.status}" /></td>
    </tr>
    </c:forEach>
    </table>
    </c:otherwise>
    </c:choose>
    </center>
    </body>
    </html>

    when should you close the connection? when you're done with it.
    how should you close the connection? like this: conn.close();
    that said, doing this in a JSP page is bad form and not recommended
    JSP's typically don't contain ANY business or data logic

  • OK now that there is no option to reveal "database" panel in DW CC, how do I create a database connection and build my phpmysql pages?

    Is there an alternative way other than manually entering PHP code?

    Thanks, It works. Author of the article politely says what many of us have to say to Adobe when they make "improvements" - WTF, Adobe???
          From: Ben Pleysier <[email protected]>
    To: Jon Lane <[email protected]>
    Sent: Saturday, January 31, 2015 1:44 AM
    Subject:  OK now that there is no option to reveal "database" panel in DW CC, how do I create a database connection and build my phpmysql pages?
    OK now that there is no option to reveal "database" panel in DW CC, how do I create a database connection and build my phpmysql pages?
    created by Ben Pleysier in Dreamweaver support forum - View the full discussionWeb development tutorial
    Deprecated Server Behaviors for Dreamweaver Creative Cloud
    WebAssist A better, more secure and future proof way MySQLi Server Behaviors
    Dreamweaver extension
    WebAssist If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7148099#7148099 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7148099#7148099 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Dreamweaver support forum by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • How to share the same Database Connection when using several Task Flows ?

    Hi All,
    I’m using JDev 11.1.1.3.0.
    I’m developing ADF Fusion Applications (ABC BC, ADF Faces…)
    These applications are deployed on a Weblogic server.
    Each application has only one Application Module.
    All Application Modules have the same connection type defined: JDBC DataSource : jdbc/GCCDS
    It is working fine.
    I’ve also developed Task Flow Applications for small thinks that are reused in multiple main applications.
    Each Task Flow Application has also one Application Module with the same connections type as main applications.
    All these task flows are deployed to JAR file (ADF Library JAR File) and are reused on my main applications. (drag and drop from the Resource Palette to ADF Regions….).
    There are some parameters passed to Task Flows, so that they can filter data depending on which main applications they are called from.
    Everything is working perfectly.
    All my main applications are using more and more task flows. Which is nice for the reusability etc…?
    Only ONE PROBLEM: DATABASE CONNECTIONS.
    Every Task Flows service made a database connection. So one user may have 10 database connections for the same adf page. And when there are 100 users that are working at the same time, it becomes a problem.
    How to share the same database connections for the main applications and all task flows which are used in the main application?
    Best Regards
    Nicolas

    Hi John,
    When I open a ADF Library JAR file of one of my task flow. (gcc_tf_recentSites.jar)
    I can see TF_RecentSitesService.xml and TF_RecentSitesServiceImpl.class in gcc_tf_recentSites.jar\mu\gcc\tf\recentSites\model\service folder
    + bc4j.xcfg in gcc_tf_recentSites.jar\mu\gcc\tf\recentSites\model\service\common folder.
    bc4j.xcfg details are
    +<?xml version = '1.0' encoding = 'UTF-8'?>+
    +<BC4JConfig version="11.1" xmlns="http://xmlns.oracle.com/bc4j/configuration">+
    +<AppModuleConfigBag ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService">+
    +<AppModuleConfig DeployPlatform="LOCAL" jbo.project="mu.gcc.tf.recentSites.model.TF_RecentSites_Model" name="TF_RecentSitesServiceLocal" ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService">+
    +<Security AppModuleJndiName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService"/>+
    +<Custom JDBCDataSource="jdbc/GCCDS"/>+
    +</AppModuleConfig>+
    +<AppModuleConfig name="TF_RecentSitesServiceShared" ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService" DeployPlatform="LOCAL" JDBCName="gccdev" jbo.project="mu.gcc.tf.recentSites.model.TF_RecentSites_Model">+
    +<AM-Pooling jbo.ampool.maxpoolsize="1" jbo.ampool.isuseexclusive="false"/>+
    +<Security AppModuleJndiName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService"/>+
    +</AppModuleConfig>+
    +</AppModuleConfigBag>+
    +</BC4JConfig>+
    So, it seems that the Application Module is packaged with the task flow....
    Is it normal ?
    Regards
    Nicolas

  • NetBean, I can't establish the oracle database connection with version 9i.

    In NetBean, I can't establish the oracle database connection with version 9i.
    I have create the datasource and it is fine.
    when i try to access the tables i get a message
    "Unable to refresh children, connection is broken, unsupported feature"
    in netbeans.
    Does netbeans support oracle 9i version.
    Thanks,
    VKK

    In NetBean, I can't establish the oracle database connection with version 9i.
    I have create the datasource and it is fine.
    when i try to access the tables i get a message
    "Unable to refresh children, connection is broken, unsupported feature"
    in netbeans.
    Does netbeans support oracle 9i version.
    Thanks,
    VKK

  • How can I create a database connection to Cloudscape database in 9iJDeveloper?

    How can I create a database connection to Cloudscape database in
    9iJDeveloper?
    thanks.

    Hi,
    I assume you have a JDBC driver for Cloudscape.
    1. In the IDE System Navigator, expand the Connections Node.
    2. Right-click on the Database Connection and choose New
    Connection .. .
    3. Click pass the welcome screen.
    4. In Step 1, name your connection and choose "3rd party JDBC
    Driver"
    5. Follow the rest of the steps and provide username/password,
    class name and URL, test and you should be ready to go.
    Good luck.

  • Error in Mysql database connectivity

    hello,
    there is problem in Mysql database connectivity.
    when i connect JSP program to Mysql database it gives error :
    Server configuration denied access to data source
    please help me asap
    kuldip jain
    [email protected]

    i m also working on Mysql Java but on Window 2000 platform
    here is the Java code which successfully runing on my machine
    import java.sql.*;
    public class TestMySql
         public static void main(String[] Args)
              try
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection C = DriverManager.getConnection(
    "jdbc:mysql://server2:3306/Db?user=root");
    Statement Stmt = C.createStatement();
    ResultSet RS = Stmt.executeQuery("SELECT * from T1");
    while (RS.next()) {
                             System.out.println(RS.getString(1));
    catch (Exception E)
    System.out.println("SQLException: " + E.getMessage());

  • How to config the oracle database connection pool in IAS

    Hi,
    Does anyone who hows to config the oracle database connection pool in IAS?
    Thanks so much!!!
    [email protected]
    Jacky

    Jacky,
    You need do the following for oracle type4 driver:
    1) register the driver:
    $IAS_HOME/bin/jdbcsetup
    Driver Identifier: Oracle_Type4_816 (whatever name you like)
    Driver Classname: oracle.jdbc.driver.OracleDriver
    Driver Classpath: .../classes12.zip (install this this zip file somewhere
    and add this zip into the Classpath later).
    2) DataSource Setup:
    start iAS Administration Tool (iASAT)
    Choose Database, unfold iAS1 (your app server instance),
    choose External JDBC Datasource -> add: DataSource Registration
    JNDI Name: yourPoolName
    Driver Type: Oracle_Type4_816 (select what you just register)
    DataSource Url: jdbc:oracle:thin:@hostName:portName:dbName
    Username: your_user_name
    Password: your_passwd
    (Datasource Pool: using defaults for now): you can also customrize the
    parameters for the pool.
    3. Add classes12.zip into CLASSPATH.
    In your application, you can use JNDI lookup to get the DataSource from
    which you get the connection from the pool.
    Hope this helps.
    Good luck.
    Xuran
    "Jacky Yan" <[email protected]> wrote in message
    news:9m0tmp$[email protected]..
    Hi,
    Does anyone who hows to config the oracle database connection pool in IAS?
    Thanks so much!!!
    [email protected]
    Jacky

  • Problem in Oracle Database Connectivity in JSP

    I am having big problem such as Oracle Database connectivity problem
    Following code i am used for database connection. but it throw an exception call class not found exception.
    Pls any one can help me. With a sample code for Oracle Database connection in JSP
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    String url="jdbc:oracle:thin:@172.25.44.54:1521:bbo";
    con = DriverManager.getConnection(url,"user", "user123");
    Thank you

    Well i've never used oracle or their drivers before but i'm presuming that you'd go to oracle.com or something and look for downloads. Otherwise you could goodle for Oracle JDBC drivers. Then just follow the instructions.
    Again i've never used JSP but if you have a manifest file somewhere you'll need to put a class-path: entry in their referecning the jar file with the driver so that it is availble at run-time.
    Wes

  • Xsql setup problem. 'Cannot acquire a database connection to process page.'

    This is probably a really basic problem, but I am getting the following error when I try to use the xsql demos.
    Oracle XDK Java 9.2.0.2.0 Production
    XSQL-007: Cannot acquire a database connection to process page.
    Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    I really don't know what I am doing wrong, so any help would be appreciated.
    My jserv.properties file:
    wrapper.classpath=s:\xdk_java\lib\xsu12.jar
    wrapper.classpath=s:\xdk_java\lib\oraclexsql.jar
    wrapper.classpath=s:\orant\jdbc\lib\classes12.zip
    wrapper.classpath=s:\xdk_java\lib\xmlparserv2.jar
    wrapper.classpath=s:\orant\xdk\admin
    Thankyou
    Adrian

    hehehhe
    I had the connection wrong in the XSQLConfig.xml file.
    It's all working nicely now.
    Ade

  • How can I stop the execution on a JSP page and start it again

    Hi
    I am making a program that simulates how to manage transactions when accessing a database by using locks. I have run into a problem and I hope someone has the time to help me.
    When a user does an update the transaction commits and releases its locks when the program executes
    <%stmt.executeUpdate("commit!"); %>
    I need to put a break in to stop the program executing this statement, to illustrate the lock is set correctly.
    I have tried to put in an alert box but this does not prevent the rest of the java code being executed.
    I have tried to use prompt boxes, JavaScript functions, but these functions cannot have any java code in them.
    I have tried using the java.swing JOptionPane boxes but this didn?t work either
    I have tried to get input from the user but I don?t know how to retrieve this data on the same page. (As far as I know you have to use submit and even refresh the page or retrieve it on the next page).
    Does anyone know how I can stop the execution on a JSP page and start it again (on same page)
    Mette

    I already have another client (Tomcat jsp application) running and it throws a SQLException correctly when I don�t put in a commit=true statement and don't close the database connection.
    But the problem is how to get the code above to stop to illustrate I have set this lock.
    I have tried to use the JOptionPane but because my program is running in a web browser I cannot use the JOptionPane dialog box.
    I have tired using an alert box but it executes the commit statement before the alert box is dispayed. So this does not work
    While (i < 2)
    if( i==1)
    %>alert(�The transactions commits when you press Ok�); <% //what it to stop execution here
    else
    stmt.executeUpdate(�commit�);
    I am not using threads so I cannot use the sleep function.
    I am using mysql and have already configured it to detect deadlocks and how long to wait for locks.
    Thanks for your help
    Mette

Maybe you are looking for

  • How can I record content FROM an iPad and then publish it back to an iPad?

    Everything I search for talks about pushing content out to an iPad, but what if I want to capture/record content from an iPad? I am trying to do a software simulation, rather than a straigh record. I did find a third party application called Reflecti

  • Complex distribution Scenario using XI: MDM GL Account Custom Repository

    Hi All, We have a complex Landscape with multiple (4) businesses (multiple R3) instances and most common R3 --> DEV 4 instances with 5 clients each, QAS 4 instances with 2 clients each with some additional clients, PRD 4 instances with a client each

  • How do you change a Photographs file name on a iMac?

    How do you change a photographs file name on a iMac?

  • LMS 3.2 Archiving Partially successful

    Hi, We have installed LMS 3.2,But for some of the switches archiving is partially successfull.Switches are 6500 in transparent mode.We use ssh for archive management.dcmaservice Log says... [ Thu Jan 21  14:51:05 AST 2010 ],ERROR,[Thread-1540],com.ci

  • Disable Auto-Mounting

    Hi Everyone, I have been searching forum after forum trying to find an answer to my question but am not having any luck. I have found one option but there has to be a better way. As I am taking a Computer Forensics major I need to disable auto-mounti