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
March 18, 2008 at 8:09 PM
Connecting a JSP page to MYSQL Database using JavaBean
File Name: beancode.java
import java.sql.*;
public class beancode {
private String username;
private String password;
private Connection con = null;
private ResultSet rs = null;
private PreparedStatement st = null;
String url = "jdbc:
mysql://localhost:3306/";;
String db = "register";
public beancode(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url+db,"root","root");
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public void setusername(String userId){
username = userId;
}
public String getusername(){
return (username);
}
public void setpassword(String pass){
password = pass;
}
public String getpassword(){
return (password);
}
public void insert(){
try{
String s1="insert into userlogin values('"+username+"','"+password+"')";
st = con.prepareStatement(s1);
st.executeUpdate();
st.clearParameters();
st.close();
}
catch(Exception m){
}
}
}
File Name: DataBase.jsp
<%@ page language="Java" import="java.sql.*" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
</head>
<body>
<form name="form1" action="beancode" method="POST">
UserName: <input type="text" name ="userId"> <br>
Password: <input type="password" name ="pass"> <br>
<input type = "submit" value="Submit">
<jsp:useBean id="beancode" class="beancode">
<jsp:setProperty name="beancode" property="userId"/>
<jsp:setProperty name="beancode" property="pass"/>
</jsp:useBean>
</form>
</body>
</html>
Database connectivity using JavaBean Example Code
Related Tutorials/Questions & Answers:
login page using jsp servlrt with mysql database?login
page using jsp servlrt with
mysql database? Description:
example:total users are 3.each use have username and password save in
mysql database table login.
After successfully login
user1 see only index
page,if user2 login
Advertisements
How to connect to MySQL in JSP?,
You can use the Java JDBC code to
connect to
MySQL database in
JSP page. Check the tutorial:
Connect JSP with
mysql
Thanks...How to
connect to
MySQL in
JSP? How to
connect to
MySQL in
JSP connect to the database from JSPconnect 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
Image upload in mysql database using jsp servletImage upload in
mysql database using jsp servlet Hello, I need code to insert image in
mysql database, I have seen the code which is already in your portal but it is not inserting image into
database it save in the folder
Connect JSP with mysql how to
connect to
MySQL database from your
JSP code. First, you need to create...)
Here is the video tutorial of "How to
connect to
MySQL Database from
JSP...
Connect JSP with
mysql
Using MYSQL Database with JSP & Servlets.
Using MYSQL Database with
JSP & Servlets.
... to
connect to the
database from
JSP page.
Send you queries... acceres the
MYSQL
database. Here I am
using MYSQL & tomcat server
Connect JSP with mysql Connect JSP with
mysql
...
Connect JSP with
mysql :
Now in the following
jsp code, you will see
how...
Output of the program when unable to
connect to specified
mysql database retrieve related data from database using jsp and mysqlretrieve related data from
database using jsp and mysql Hi sir,
please give some example of
jsp code for retrieving
mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
jsp page to add users to mysql databasejsp page to add users to
mysql database <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-bean.tld..." %>
<%@
page contentType="text/html" pageEncoding="UTF-8"%>
jsp page to add the user to mysql databasejsp page to add the user to
mysql database adduser.jsp:
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF..." prefix="logic" %>
<%@
page contentType="text/html" pageEncoding="UTF-8
not able to connect to mysql using.. jdbc not able to
connect to
mysql using.. jdbc i am not able to
connect to
mysql using jdbc ..
is there any classpath that i need to set..because i am
using mysql-connector-java jar file..to
connect to
mysql..
Pls provide the steps
Backup MySQL Database - JSP-ServletBackup
MySQL Database
Database Sir I have been reading Rose's india tutorial "
Using MySQL Database with
JSP/Servlet". In the Tutorial you have shown an example of backing up the
database. When I tried to backup
database how to connect jsp to mysql - Java Beginnershow to
connect jsp to mysql I m new in
Mysql and
JSP i m ceating.java file
using bean file for connectivity
but i m not able to
connect jsp... me hw to conncet
jsp with
mysql
this is connection file
package
connect problem connect jsp and mysql - JSP-Servletproblem
connect jsp and mysql hello,
im getting an error while connecting
jsp and
mysql.
I have downloaded the driver
mysql-connector... Software Foundation\Tomcat 5.5\common\lib\
mysql-connector-java-2.0.14.jar
database connectivity using mysqldatabase connectivity
using mysql java file: eg1.java
package eg... seconds)
I am
using Netbeans 5.5,
mysql server 5.0, to get data from table...[]) throws SQLException
{
try
{
String connectionURL = "jdbc:
mysql