How to connect to database in JSP

Hi, all.
I am using J2EE and cloudscape. I have written all the EJB classes. But now i have no idea that how to connect to database in jsp such as i get user ID from portal, then i connect to database check the existence of user ID and the password then return true or false value. how to write all this in jsp?
Thanks very much!
yayun

this is the required code
i hope this will help u
<html>
<head>
</head>
<body>
<%@ page import="java.sql.*" %>
<%
try
String fu=request.getParameter("username");
String fp=request.getParameter("password");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection Con=DriverManager.getConnection("jdbc:odbc:wind","","");
Statement stmt=Con.createStatement();
ResultSet rs=stmt.executeQuery("select * from table1 where username='"+fu+"' and password='"+fp+"'");
if(rs.next())
%>
<jsp:forward page="success.jsp"/>
<%
else{
%>
<jsp:forward page="unsuccess.jsp"/>
<%
catch(Exception e)
%>
</body>
</html>

Similar Messages

  • How to connect MySql database with JSP

    Dear everyone,
    how to connect MySql database with JSP......

    It's too bad that nobody has ever asked this question before...

  • How to connect cloudscape database to jsp

    could someone help

    sorry im using ibm websphere and creating a dynamic web project that displays the contents of my cloudscape database when the JSP is ran on the websphere test server...no idea what im doin...if anyone has any help at all i would appreciate it quite a bit

  • Hi guys Pls tell me a way to connect db4 database with jsp and which driver

    hi guys
    Pls tell me a way to connect db4 database with jsp and
    also tell me which driver i have to use
    also tell me how to connect with excel sheets

    take a look at the follwing links. There, you'll find all what you need :
    DB4:
    http://www.oracle.com/database/berkeley-db/je/index.html
    http://www.oracle.com/technology/products/berkeley-db/je/index.html
    http://www.oracle.com/database/berkeley-db/db/index.html
    http://www.oracle.com/database/docs/berkeley-db-je-datasheet.pdf
    Excel:
    http://64.18.163.122/rgagnon/javadetails/java-0516.html
    Hope That Helps

  • How to connect mysql database using xml

    welcome to all,
    here my doubt is how to connect mysql database using xml file, how to integrate xml file and jsp file and how to access data from dabase using jsp file. can any one help me
    regards

    Short answer: you wouldn't do any of those things. The first two are meaningless and the third is a bad practice. I have no idea what those ideas were supposed to achieve so I have no idea what tutorials I should suggest to you.

  • How to connect mySQL database with jdbc

    Who can tell me how to connect mySQL database with jdbc? Thanks

    http://onesearch.sun.com/search/developers/index.jsp?and=connect+mysql&nh=10&phr=&qt=&not=&field=title&since=&col=devforums&rf=0&Search.x=24&Search.y=16

  • How to connect one database in two threads?

    Dear All,
    If anyone can tell me how to connect one database concurrently?
    I tried the following idea:
    1.create a Hashtable to keep database objects(those databases have been opened)
    2.Before openning(connecting) a database:first step is to check the hashtable.
    If the the database object is in the hashtable, this object will be returned.
    If the datatbase object is not in the hastable, open the database and store this opened database object into the hashtable.
    I failed the test of this implementation. My test is:Create two threads (extend java Thread class).In each of these two threads, try to open the same database.Just like the following:
    MyThread thread1 = new MyThread();
    MyThread thread2 = new MyThread();
    thread1.start();
    thread2.start();
    I guessed the database object in the hashtable would be returned in the second thread.Unfortunatly, I only got an exception which meant the database couldn't be opened twice.It looks like the second thread happened before the opened database object stored into the hashtable.
    I cannot figure out if my design is wrong or my test application is wrong.
    I really appriatiate your attentions!!!
    Lu

    um not sure i follow exactly but in your code add the word synchronise to it and this means only 1 tread can access it at any 1 time.
    So your could have a class which is a singleton so it only opens the dbase once and then all other access share your connection.
    so
    public class foo{
    foo INSTANCE = new foo();
    private foo(){} //private constructor
    then all your methods use foo's internal dbase connection. Am i making sense

  • How to connect sybase database in JDeveloper 11g using JConnect

    Hi
    How to connect sybase database in JDeveloper 11g using JConnect? Please help.

    User,
    It would help if you explained Sybase Jconnect instead of leaving us to google.
    At any rate, it appears you need to create a library definition in JDeveloper, add the appropriate JConnect JAR files to the library's classpath, and then add the library to your project.
    John

  • How to connect Oracle database in VC++.06

    How to connect Oracle database in VC++.06 please give me details

    on the Insert command button and add the following code to the button click event:
    try
    string results = "";
    OracleConnection con = new OracleConnection("DSN=Employee;uid=system;pwd=test");
    con.Open();
    .....................................................................

  • How to connect external database(Ex:SQL Server/Tivoli)  from ABAP Webdynpro

    Hi,
    Any one have idea how to connect external database like SQL Server/Tivoli to access tables from WebDynPro ABAP.
    Please point to me some links if you have
    Thanks
    Praveen

    Hi,
    Please check out this link -
    FETCH DATA FROM ORACLE DATABASE USING Web Dynpro
    Regards,
    Lekha.

  • How to connect oracle database from tuxedo

    Hi,
    How to connect oracle database from tuxedo.
    If any one can help me.
    Regards,

    it depends on configuration your going to choose, there are two ways--
    - Using X/Open standards, for this
    you have to make an entry of Resource manager in $TUXDIR/udataobj/RM file.
    Then in UBBConfig file in GROUPS section u have to set Openinfo.
    It also depend on which database you are going to use.
    In your service now you need to call tpopen() API from tpsvrinit() function.
    - Other possibility is, take an implicit connection using Pro*C or Pro*Cobol whatever platform you are using.
    EXEC SQL Connect ...

  • How to connect oracle database using jsf

    how to connect oracle database using javaserver faces with connection pooling

    Here is one way...
    http://jakarta.apache.org/commons/dbcp/

  • How to connect oracle database with JAVA

    how to connect oracle database with JAVA....
    using j2sdk and Jcreator . which connector to use .. what are the code for that ..

    PLEASE .... Ask in an Oracle Java forum.
    And read the documentaiton. There is a whole document devoted to doing that. http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/toc.htm has examples.
    PLEASE ... do not ask product questions in a forum which clearly has a title saying it is devoted to assisting with download problems.

  • How to connect oracle database into VC?GIve step by step.

    Hi Experts,
    Please help
    How to connect oracle database into VC?
    I need step by step.
    what shall i do the first to connect via jdbc or  something else.
    whether we have to create dsn name or using jdbc connections?which one to use?
    Please give the basic steps.Its very urgent.
    Thanks and Regards,
    Nutan

    Hi ,
    all information are in the following document:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424">How to Configure a Business Intelligence JDBC System for Visual Composer</a>
    Rgds,
    Karim

  • How to connect labviewv database toolkit to SQL CE server

    Dear sir,
                      i am using labview 8.2.1 and Database Connectivity 8.2.i need same simple  concept of how to connect  LV database toolkit to SQL CE Server.

    When opening the database connection, you will need to provide either a connection string, or a path to a UDL (which will contain a conenction string). The easiest way to get a connection string is to go to (no I am not kidding) www.ConnectionStrings.com. Once there you enter the type of DBMS you are trying to connect to, and the system will list connection strings that you can use based on the drivers that you're using.
    How much experience do you have with LV and/or databases?
    Mike...
    PS: you might also want to check out a series I did a bit ago on database connectivity in my blog. See the link in my signature...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Maybe you are looking for

  • Calling another program and waiting for output

    Hi, I'm writing a program that passes a file created for an application called Net Sim but has to wait for the output. Net Sim lies in another directory from the java files and I don't know how to call the program with the file created as a parameter

  • 10.5.3 Outgoing Mail Issue

    Greetings, I recently updated to 10.5.3. Right after this was done I began experiencing issues with sending and receiving email. The error returned is as follows: Cannot send message using the server X. Verify that you have addressed this message cor

  • Calibration Executive fails to generate pdf reports

    I have Calibration Executive 3.4.1 and it has stopped generating pdf, word, or excel reports. It still generates text and html reports. I reinstalled cal exec and made sure it as all the current updates. The only thing we changed lately was installin

  • Ipod showing no songs on pod...

    I have a new 60Gig Video/Picture Ipod. It is 2 months old. Just today, I was updating songs and videos from iTunes onto my Ipod. I disconnected it perfectly fine and right. When i went to look for songs and videos on my Ipod, they were not found. All

  • Has anyone managed to connect a canon 5d3 to FMLE for live streaming?

    Been trying to get this sorted for a project but its not proving simple at the moment. Any help at all will be appreciated