Using javabeans to connect mySQL database on a jsp page

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

View Answers

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:
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
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 database in php using mysql
how to connect to database in php using mysql  how to connect to database in php using mysql
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
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 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
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
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
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
Image upload in mysql database using jsp servlet
Image 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   
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...; This tutorial shows you how to connect to MySQL database and retrieve the data... driver org.gjt.mm.mysql.Driver Driver to connect to the database. Class.forName
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:ADS_TO_REPLACE_1 http://www.roseindia.net/jsf/myfacesspring
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html... {color:blue} <%@ page import="java.sql.*" %> <%@ page import
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 a web page to a database
connect a web page to a database  how to connect a web page to a database
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
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp... stored in the database using jsp servlet then want to show the result in the next jsp page. any one help me out
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
linking jsp with database using classes and methods and then access them all in to my jsp page - JSP-Servlet
linking jsp with database using classes and methods and then access them all in to my jsp page  how to connect jsp page with mysql using classes... all with the help of java beans in u'r own jsp page
retrieve related data from database using jsp and mysql
retrieve 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
Data needs to be gathered in XML file from the database (MySql) using JSP
in XML file from the database (MySql) using appropriate JSP/Java Bean functions...Data needs to be gathered in XML file from the database (MySql) using JSP ... files. using following database create database music; use music; CREATE
jsp page to add users to mysql database
jsp 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 database
jsp 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
Create a Table in Mysql database through SQL Query in JSP
; This is detailed java code to connect a jsp page to mysql database and create a table of given... Create a Table in Mysql database through SQL Query in JSP... in mysql database using jsp</title> </head> <body>
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert name ,city and image in database in mysql and jsp   Here is an example in jsp that insert name, city and image to database. <%@ page import
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
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next..._name where id=..; database:mysql technology:jsp,servlet,javascript,jstl  ...://www.roseindia.net/jsp/navigation-database-table.shtml   follow this code
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ips?user=root&password=mysql"); } catch (SQLException
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ips?user=root&password=mysql"); } catch (SQLException
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ips?user=root&password=mysql"); } catch (SQLException
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
Backup MySQL Database - JSP-Servlet
Backup 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
Using MYSQL Database with JSP & Servlets.
how to connect jsp to mysql - Java Beginners
how 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-Servlet
problem 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
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
what is the mysql in the database using php
what is the mysql in the database using php  what is the mysql in the database using php  Please visit the following link: PHP Database
what is the mysql in the database using php
what is the mysql in the database using php  what is the mysql in the database using php  Please visit the following link: PHP Database
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status" I am thinking to use a map of seats ( with pictures controllers as seats) What
database connectivity using mysql
database 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
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
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it   I have tried the following code Database creation... processing JSP page /databaseinsertion.jsp at line 117 114: 115: finally
Connect from database using JSP Bean file
Connect from database using JSP Bean file...;h1>JSP using JavaBeans example</h1> <form name="form1" method...="sample" class="myexample.bean" scope="page">    <jsp

Ads