February 5, 2009 at 3:54 AM
Action file :
<%@ page language="java" import="java.sql.*" import="java.util.*" %>
<%
String userid = request.getParameter("userid");
String password = request.getParameter("password");
Connection con = null;
String url = "jdbc:
mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";
try {
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,pass);
Statement st = con.createStatement();
String strQuery = "select * from login where userid='"+userid+"' and password='"+password+"'";
out.println(strQuery);
ResultSet rs = st.executeQuery(strQuery);
while(rs.next()){
if((rs.getString(1).equals("admin")) && (rs.getString(2).equals("admin")))
{
session.setAttribute("userid",userid);
response.sendRedirect("userForm.jsp");
}
if((rs.getString(1).equals("user")) && (rs.getString(2).equals("user")))
{
session.setAttribute("userid",userid);
response.sendRedirect("registrationForm.jsp");
}
else{
response.sendRedirect("loginForm.jsp");
}
}
System.out.println("Connected to the database");
con.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
---------------------------------------------
Visit for more information:
http://www.roseindia.net/jsp/Thanks.
Amardeep
Related Tutorials/Questions & Answers:
JSP- common dbase connection - JSP-ServletJSP-
common dbase connection Hi!
Thanks for your suggession regarding Live news... Now it is working....
I have a small doubt in
dbase connection.... I want to write only one
dbase connection and i want to call
Dbase connection - JSP-ServletDbase connection Hi!
how to write
common dbase connection for all
JSP pages. In how many ways we can write this...
send me any code if u have..........
Thanks in advance
Advertisements
Common connection in JSP - JSP-ServletCommon connection in JSP Hi
I am creating an
JSP application.
I want to use a
common JSP page so that I can include it into other pages and get
connection to database.
I am able to get
connection in other(
common)
JSP dbase store - JSP-Servletdbase store HI!
In my project i have to store phone number in
dbase. i used numeric (11,0) as data type for phone number. When i am trying to store...". If i am storing 9 numbers it is storing in
dbase...
What's wrong
connection of jsp with mysql - JSP-Servletconnection of
jsp with mysql can anybody tell me about
connection of
JSP with MYSQL? and also tell me which version is compatible with tomcat 4.1 i am using tomcat 4.1, MYSQL 5.0 but i have problem with
connection connection to mysql in jspconnection to mysql in jsp please i got this error message when trying to connect to mysql database in
jsp.
Unknown character set: 'utf8mb4
jsp connection to db2jsp connection to db2 hello friends i have a project to do in
jsp using db2 database can anyone please help me in connecting a
jsp page to db2 database??
please frienda help me
Connection Pooling - JSP-ServletConnection Pooling Hi All,
Iam new to
Connection Pooling in Java. I need to create
connection pooling for my MySQL Database with
JSP using Bean...
Connection con=null;
public static
Connection getConnection()
{
try
connection with database - JSP-Servlet and the
connection with the database using
jsp code, I get exceptions that I have... with java code.
Is there any other way to establish a
connection with database in
jsp...
connection with database I tried the DSN and
connection jsp/mysql connectionjsp/mysql connection I am puttng the following files in the lib folder of jdk to connect
jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect
jsp and mysql
jsp/mysql connectionjsp/mysql connection I am puttng the following files in the lib folder of jdk to connect
jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect
jsp and mysql
JSP - MySQL - ConnectionJSP - MySQL - Connection I can't connect mysql using
jsp in my server.It shows some error like this.
""" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received
Use of Connection Pooling - JSP-ServletUse of
Connection Pooling Dear Friends
i want to use
connection pooling in my
jsp page i created one connectionPooling.java is :
package...
Connection con=null;
public static
Connection getConnection()
{
try
connection with mysql with jstl - JSP-Servletconnection with mysql with jstl hi, i m working on jstl . i hv done
connection in MS -Access with JSTL .
The code is working well. but when i am trying to connect database with mysql 5.0 it is creating problem.
Plz tell me
jsp to cassandra datbase connection by using eclipsejsp to cassandra datbase
connection by using eclipse sir i want to connect the apache cassandra datbase by using cql query language.
i am success by using simple java application.now my task is to interact with cassandra
code for jsp to db connection using jdbccode for
jsp to db
connection using jdbc please send me the code...;html>
<form method="post" action="http://localhost:8080/examples/
jsp...("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con
Java Thread not geting Connection pool - JSP-ServletJava Thread not geting
Connection pool Hi All,
Please help me in following problem.
I have database
connection on server using
connection pool... while getting database
connection in Background process.
I am passing
JSP - JSP-ServletJSP Hi!
In my
JSP page I am entering values and submitting the values. In
common way I have to receive those values in another
JSP using... to receive values in second page.
I want to write
dbase connections
connection connection how to make multiple database
connection using jdbc
connectionconnection How to get connected to my database using
jsp
Please visit the following links:
http://www.roseindia.net/
jsp/connectjspwith_mysql.shtml
http://www.roseindia.net/
jsp/displaydatafrom_database1.shtml
http
connection the
connection with the
available port on the host machine:
import java.net.... the
connection was not established. Predict the output of the preceding
code. Explain why the
connection cannot be established
JSP - JSP-ServletJSP what are the other options to connect the
dbase from
JSP page except beans. I dont want to write
connection in each and every page.. Is there any other way.
Pls... help me........ Hi friend,
Use Hibernate
JSP phone number - JSP-ServletJSP phone number Hi!
when i am trying to insert phone number in
dbase. Only 9 numbers are inserting. i have given data type as numeric(11,0). I... into
dbase directly....
Thanks in advance
core java - JSP-Servlet that "use only one class file. In that class file write all the
connection to
dbase,Update,insert,delete functions to the different
JSP pages. From ur
JSP page... it is working...
In my project I have to insert the data from different
JSP pages. I know
jspjsp Hi
How can we display sqlException in a
jsp page?
How can we mantain session in
jsp?
Thanks
Kalins Naik
JSP SQL Exception
<...;html>
<head>
<title>
Connection with mysql database</title>
jsp - JSP-Servlet dbase.
i am receiving the values in 2nd
JSP. when i go to check condition i am...jsp Hi! Everybody...
I have two
JSP pages. In 1st
JSP i have two... selects university and press submit in 2nd
jsp i have to display university names
jsp - JSP-Servlet("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc... that is state. In the state table
dbase i have this countryid. pls.. help me...");
PrintWriter pw = response.getWriter();
Connection con = null
jsp jsp sir i am trying to connect the
jsp with oracle connectivity... are using oracle oci driver,you have to use:
Connection connection... are using oracle thin driver,you have to use:
Connection connection