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

Similar Messages

  • 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

  • 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

  • Database connection with jsp?

    any database (access preferred)

    kajbj wrote:
    What's the question?"give me teh codez", of course. ;-)

  • 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

  • JDBC-ODBC connectivity from JSP page

    hi
    i am trying to connect a jsp page with database using jdbc-odbc driver. i have created a dsn with the name 'test' that connects to a database 'test' in SQL server. the following lines has been added to the web.xml file placed in the \WEB-INF folder
    <context-param>
    <param-name>
    javax.servlet.jsp.jstl.sql.dataSource
    </param-name>
    <param-value>
    jdbc:odbc:text, sun.jdbc.odbc.JdbcOdbcDriver
    </context-param>
    i have also placed the rt.jar file in the \WEB-INF\lib folder. but, when i run the jsp page and ty to make any database interaction, an expection occurs
    java.lang.ClassNotFoundException : sun.jdbc.odbc.JdbcOdbcDriver
    please help

    I think you need to download the JDBC/ODBC driver jar file into your project. For example, if you need a JDBC driver for the Oracle database, you search google for 'oracle jdbc driver'. Its driver is something like classes14.jar. I suggest you create and test your database connection pool in a servlet so you will have an easier time debugging any issues in getting it to work.
    Also, as the previous post points out, JSP is for displaying data and submitting user input back to the servlet. Put all your business logic in the servlet, put any data you get from the database in request scope by the servlet, dispatch to the JSP page so it can be displayed. This is a crude example. For a better design read up on MVC (Model View Controller) design.

  • 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

  • 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

  • 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

  • Embedding SWF file with SAP Netweaver BI Connection to JSP page

    All,
    Is it possible to embed a SWF file with SAP Netweaver BI connection that is already published in BW system to a JSP page?
    Thanks...

    Hallo,
    embedding the published web-template via iframe into the jsp should work:
    <iframe id="test" src="/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap.pct!2fplatform_add_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.bex?DASHBOARD=TECHNICAL_NAME_DASHBOARD" width="600" height="800" />
    Regards,
    Roman

  • Error while connecting to the database from a JSP Page

    Hi,
    I am using a simple JSP page which is based on the sample JSP pages from OTN.
    When I try to connect to my database using the following code:
    InitialContext ic = new InitialContext();
    OracleDataSource ds = (OracleDataSource)ic.lookup("jdbc/OTN9iDS");
    m_connection = ds.getConnection();
    I get the following error:
    Naming exception Error while connecting to the database : javax.naming.NameNotFoundException: jdbc/OTN9iDS not found in JDBCTest-JDBCTestProject-webapp
    Does anybody know wht this is happening?
    Any help would be appreciated
    FRank

    Hi Frank,
    Are you using standalone OC4J or 9iAS ? If you are using standalone OC4J then you need to add a proper data source entry in %OC4J_HOME%j2ee\home\config\data-sources.xml file.
    If you are using 9iAS the you can log in to the Enterprise Manager console and add the data source entry by using wizard provided by 9iAS.
    Ensure the case of the JNDI lookup string, since, it is case sensitive.
    Hope this helps.
    Abhijeet

  • What kind of database can I use with jsp pages?

    Well I have been an ASP programer for a while and now I want to be able to host sites on an Apache server so that means i need to just jsp pages or something that is not windows dependant. So I need to start a database, a small one just for client information, and I don't know what to create it in. I was going to use MS acess but I am guessing that won't work with jsp. So what are my options for desktop database applications? Should I download star office and try that I havne't ever used that but I imagine it comes with some kind of database program. Well let me know thanks.

    JSP should work with any database that worked with ASP. The key is to use JDBC which is the equivalent to ADO. As long as you get the appropriate driver for the database, you're all set. As the previous poster mentioned, for MS Access you must use a JDBC-ODBC bridge which is really a JDBC driver that works on top of ODBC. This is the worst performing type of driver, but if you're using MS Access then perhaps performance isn't a priority.
    Check out the Sun tutorial on JDBC if interested.

  • How to reuse a 9iAS Portal database connection in a BC4J application?

    Hi,
    I have a 9iAS Portal 9.0.2 application, and I want to call a BC4J/UIX application from the Portal application. Ideally I would like to reuse the database connection already established within Portal, because it has authenticated the user with the SSO, and has all of the Portal and VPD settings already in the environment. I don't want to ask the users to re-log in.
    I have looked at the Portal Java PDK and cannot find anything appropriate - has anyone accomplished this, or is there another way of doing this?
    Thanks,
    Steve

    BC4J supports JAAS authentication.. look at the jazn stuff. When u deploy your application on 9ias one of the pages in the wizard asks what kind of authenticatoin you would like to use, you might be able to set something up there...
    Also you an secure the URL in the httpd.conf file so that if a user directly attemps to access that application they are presented with the SSO log in screen.

  • Database connectivity in JSP

    Hi all,
    i am new to JSP and first time trying this code.i am trying to make a connection with the database,there is some problem in SQL.it show me SQLException.
    Here is code connec.jsp:
    <%@ page import="java.sql.*" %>
    <% String name = request.getParameter("name");
    String age = request.getParameter("age");
    %>
    <%
    Connection conn = null;
    Statement stmt = null;
         PreparedStatement pstmt = null;
    ResultSet rs = null;
         try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn = DriverManager.getConnection ("jdbc:odbc:unsoda_project","project_unsoda","project");
         }catch (Exception e) {
              out.println(e);
    %>
    <!-- To read values from the database -->
    <TABLE>
    <%
         try {
              stmt = conn.createStatement();
              rs = stmt.executeQuery("Select codes from code_filter where codes > 1020");
              while(rs.next()) {
    %>
    <TR><TD><!%rs.getInt()%></TD>
    </TR>
    <%
         }catch (Exception e) {
              out.println(e);
    %>     
    </TABLE>
    %>
    When i tried to see the output through web browser it show me Exception:
    /*java.sql.SQLException: [Microsoft][ODBC driver for Oracle][Oracle]ORA-00913: too many values */
    Now pls. tell me how do i do this connectivity and can diaplay the output of the query into the combo box.
    Thank you,
    sonika

    which of your catch blocks is throwing the exception. From the looks of the message, the ODBC driver is having and argument with the oracle driver based on your query. It says it is wrong. You shouldn't get the error about parameters if your driver doesn't connect, so I don't think that's the problem, I think it is your query.

  • Database access with JSP custom tags

    i have created one file in which i am making the connection with mysql data base with con.mysql.jdbc.Driver.and usking J connector and that i'm doing with custom tag.this is the error which i'm getting in tomcat.
    and the tag handler class and TLD file and jsp file is below
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: javax.servlet.jsp.JspException: null
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl .java:841)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.j ava:778)
    org.apache.jsp.DbTry_jsp._jspService(org.apache.jsp.DbTry_jsp:72)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NullPointerException
    Try.Connect.<init>(Connect.java:26)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    java.lang.reflect.Constructor.newInstance(Unknown Source)
    java.lang.Class.newInstance0(Unknown Source)
    java.lang.Class.newInstance(Unknown Source)
    org.apache.jasper.runtime.TagHandlerPool.get(TagHandlerPool.java:116)
    org.apache.jsp.DbTry_jsp._jspx_meth_db_connect_0(org.apache.jsp.DbTry_jsp:84)
    org.apache.jsp.DbTry_jsp._jspService(org.apache.jsp.DbTry_jsp:62)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
    Apache Tomcat/5.5.4
    Tag handler class
    package Try;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspWriter;
    import javax.servlet.jsp.PageContext;
    import javax.servlet.jsp.tagext.TagSupport;
    import java.sql.*;
    public class Connect extends TagSupport {
    private String driver = "com.mysql.jdbc.Driver";
    private String dbtype = "mysql";
    private String host = "localhost";
    private String username = "root";
    private String password = "203131";
    private String database = "compose";
    private String scope = "page";
    private String id = "";
    JspWriter out = pageContext.getOut();
    public void setDriver(String str) {
    driver = str;
    public void setDbtype(String str) {
    dbtype = str;
    public void setHost(String str) {
    host = str;
    public void setUsername(String str) {
    username = str;
    public void setPassword(String str) {
    password = str;
    public void setDatabase(String str) {
    database = str;
    public void setScope(String str) {
    scope = str;
    public void setId(String str) {
    id = str;
    public int doStartTag() throws JspException {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    String url= "jdbc:" + dbtype + "://" + host + "/" + database;
    Connection connection = DriverManager.getConnection(url,username,password);
    out.println("right ;;one");
    catch (SQLException e1) {
    System.out.println("Error in HeadingTagv: " + e1);
    catch (Exception e) {
    System.out.println("Error in HeadingTag: " + e);
    return SKIP_BODY;
    TLD is lib.tld
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>db</short-name>
    <display-name>Database Tags</display-name>
    <description>
    A set of tags for working with SQL database access
    </description>
    <tag>
    <name>connect</name>
    <tag-class>Try.Connect</tag-class>
    <body-content>empty</body-content>
    <description>
    </description>
    <attribute>
    <name>driver</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    </description>
    </attribute>
    <attribute>
    <name>dbtype</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    </description>
    </attribute>
    <attribute>
    <name>host</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    Can be given by a run-time expression.
    Host name of the computer where database is located.
    Default is "localhost".
    </description>
    </attribute>
    <attribute>
    <name>username</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    Can be given by a run-time expression.
    Username for logging onto the database.
    Default is "root".
    </description>
    </attribute>
    <attribute>
    <name>password</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    Can be given by a run-time expression.
    Password for logging onto the database.
    Default is the empty string.
    </description>
    </attribute>
    <attribute>
    <name>database</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <description>
    Can be given by a run-time expression.
    The name of the database that will be used for
    the SQL commands. Default is no database specified.
    </description>
    </attribute>
    <attribute>
    <name>id</name>
    <required>false</required>
    <description>
    </description>
    </attribute>
    <attribute>
    <name>scope</name>
    <required>false</required>
    <description>
    </description>
    </attribute>
    </tag>
    </taglib>
    JSP file is
    <%@ taglib uri="/WEB-INF/lib.tld" prefix="db" %>
    <html>
    <body>
    <db:connect username="root" password="203131" database="compose" />
    </body>
    </html>

    Answered in your other post:
    http://forum.java.sun.com/thread.jspa?threadID=608780&tstart=0

Maybe you are looking for