Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Interview-Questions connect to the database from JSP
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vijay Kumar
connect to the database from JSP
3 Answer(s)      4 years ago
Posted in : JSP-Interview Questions


How do you connect to the database from JSP?


Advertisement
View Answers

October 30, 2010 at 12:56 PM


A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets.



April 5, 2011 at 11:24 PM


<%@ page import="java.sql.*" %> <%! String Uname_Text; String Passwd_Text;%> <% Uname_Text=request.getParameter("Uname"); Passwd_Text=request.getParameter("Passwd"); request.setAttribute("Uname",Uname_Text);

try{

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}

    catch(Exception e){ out.println("Driver Detection Failed.");  }

    try{
    Connection conn;
    Statement stm;
    String db = "jdbc:odbc:test";


     conn = DriverManager.getConnection(db,"","");
    System.out.println("****Connected to database***");

stm = conn.createStatement();

    if(Uname_Text=="" || Passwd_Text=="")
    {

        response.sendRedirect("http://localhost:4040/Myjsp/Login_Fail.jsp");
        out.println("Username is empty.");
    }

ResultSet rs = stm.executeQuery("select * from Table1 where UnameTable='"+ UnameText +"' AND PasswdTable='"+PasswdText+"'"); while(rs.next()) {

            out.println(rs.getInt(1) );



            out.println(rs.getString(2) );

            out.println(rs.getString(3) );
            out.println(rs.getString(4) );
            out.println(rs.getString(5) );
            out.println(rs.getString(6) );
               out.println(rs.getString(7)); 

            out.println();
            out.println("");


        }

conn.close();

    }

catch(SQLException e) {

    }

%>



April 5, 2011 at 11:28 PM


this shows the connection as well as insert command....for update use executeUpdate("upadate command here");



Related Tutorials/Questions & Answers:
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
Connect to the database
Connect to the database  how to connect to the database in the iphone
Advertisements
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before... DSN will get created. 6) Restart your server and run your jsp code. Here is your
use properties file to connect to the database in jsp..
use properties file to connect to the database in jsp..  How to use properties file to connect jsp code with database ..........   Here is a jsp code that connects to database using properties file. <%@page import
i can not connect to database in servlet - JSP-Servlet
i can not connect to database in servlet  Hi I am following... offer .   Hi friend, Code to connect to database in servlet... to a databse by a servlet.I used the example in "Inserting Data In Database
i can not connect to database in servlet - JSP-Servlet
i can not connect to database in servlet  Hi I am following... offer .   Hi friend, Code to connect to database in servlet... to a databse by a servlet.I used the example in "Inserting Data In Database
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
Connect JSP with mysql
you how to connect to MySQL database from your JSP code. First, you need to create database and then write jsp code to connect jsp to database. 1. Create... database in my sql command prompt) 2. Connect JSP with mysql: 
Connect from database using JSP Bean file
Connect from database using JSP Bean file...; is doing the loading of bean file from the classes. <jsp:useBean id...; Java Beans are reusable components. It is used to separate Business logic from
TO connect multiple database
TO connect multiple database  How to connect several database from a single application in java depending upon the user input it will connect to that database
Using javabeans to connect mySQL database on a jsp page - JSP-Interview Questions
Using javabeans to connect mySQL database on a jsp page  Hi, Am doing my project and I don't know how to connect a jsp page to a mySQl database...; Connecting a JSP page to MYSQL Database using JavaBean File Name: beancode.java
how to connect the database using hibernet through servlet/jsp through form
how to connect the database using hibernet through servlet/jsp through form  plz give me the reply   Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/myfacesspring/loginRegistration.shtml Hope
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data.... If I use it also, unable to connect to backend oracle database. Let me... max("+pkid+") from "+tableName); if(rs.next
connect a web page to a database
connect a web page to a database  how to connect a web page to a database
connect database with javascript
connect database with javascript  can you please tell me how to connect database with javascript code. balaji.sivaramgari@gmail.com this is my mail id thanks in advance
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample... which is connect to database using jdbc database
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
Connect database in Access to Netbean?
Connect database in Access to Netbean?  how to connect database in micrsoft access to Netbean?i know it can be connected by using JDBC-ODBC bridge, can i know the steps in connecting the database? Is there any source code
Update Database from jsp
Update Database from jsp   I want to update my oracle database column from a text box ,so whenever I input some text value in the text box and click UPDATE button the database field should be updated . I have a drop down menu
line chart from database in jsp
line chart from database in jsp  how can i create line chart from database in jsp code
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName
Display Data from Database in JSP
Display Data from Database in JSP    This is detailed java program to connect java application with mysql database.... This is first jsp page that has a link 'show data from table', user can show
How to connect with database
How to connect with database  jdbc connection
How to connect to MySql Database from Servlet?
; font-weight: bold; } How to connect to MySql Database from Servlet... will show you how to connect to MySQL database and perform select operation. You will learn the JDBC steps necessary to connect to the MySQL Database and execute
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code. try { Driver d=(Driver)Class.forName
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date... not available in database field than show in green color and clickable. NOTE :- Date
how to connect program to database
how to connect program to database  Sir i want ur help in my program. I want to save the data in the database. When i'll click on save button the entered data must be save in the database. I want an action performed method
connect with Database - SQL
connect with Database  Hi, when ever i m trying to connect with 10g ..i m getting error .. Failed to get a connection org.jboss.util.NestedSQLException: Could not create connection; - nested throwable
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
Advertisements
 

 

 

DMCA.com