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



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

Have Programming Question? Ask it here!
 
 
 


Vijay Kumar
connect to the database from JSP
3 Answer(s)      3 years and 10 months 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
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
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
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
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
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
search functionality using jsp from database
search functionality using jsp from database  search functionality using jsp from database
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Loading a jsp page (with record from database) from another jsp page
Loading a jsp page (with record from database) from another jsp page  Suppose I have two jsp pages Search.jsp and Getdata.jsp. There are two fields... with records from database(against Serial no and year).That is, as soon
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named...;body> <h2>Data from the table 'stu_info' of database 'student'</h2... and password to connect to database. */ connection
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
how to connect to database in php using mysql
how to connect to database in php using mysql  how to connect to database in php using mysql
Connect JSP with mysql
; This query creates database 'usermaster' in Mysql. Connect JSP with mysql : Now in the following jsp code, you will see how to connect... Connect JSP with mysql   
getting values from database - JSP-Servlet
JSP code separately.If it will not display database values then try your code...getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now
connect jsp with tomcat - JSP-Servlet
connect jsp with tomcat  hello friends, i have severe problem in making connection between tomcat 6.0.18 and jsp pages.my system configuration... web.xml file.. or put your jsp prg folder in jsp-examples only, you can send
autocompletion in textfield fetching from database in jsp
autocompletion in textfield fetching from database in jsp  hi i want to retrieve country name from mysql db to textfield.. maeans if anyone type... i caant able to select particular name to textfield... it should be in jsp
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
how to connect mysql from gui?
how to connect mysql from gui?  i am unable to connet to mysql server from my projet that is gui for mysql...can anyone help me in this...its urgent? i have to connet to mysql from gui..   Hi Friend, Try the following
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... example which lets you understand to fetch data from database in JSP
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity with database from my web site. In my local host-- when I am typing
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity with database from my web site. In my local host-- when I am typing following code
Advertisements
 

 

 

DMCA.com