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



Home Answers Viewqa JSP-Interview-Questions Using javabeans to connect mySQL database on a jsp page

Have Programming Question? Ask it here!
 
 
 


Martin
Using javabeans to connect mySQL database on a jsp page
1 Answer(s)      6 years and 5 months ago
Posted in : JSP-Interview Questions


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


Advertisement
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
connect a web page to a database
connect a web page to a database  how to connect a web page to a 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
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
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
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
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
Connect JSP with mysql
you how to connect to MySQL database from your JSP code. First, you need... database in my sql command prompt) 2. Connect JSP with mysql: ... 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... web application. Creating Table in the database. Using a JDBC driver
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   
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
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
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...;head> <title>Create table in mysql database using jsp<
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
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
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
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
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
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
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
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
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
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
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
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
how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program... the response from the servlet page. DataInputStream...(); String userid=connect(user.toLowerCase().trim(), pwd.toLowerCase().trim
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
Mysql connect
Mysql connect  i can have a mysql database file and mysql-connector-net .but i have not mysql database. how to connect vb.net thsis database.(C:\Documents and Settings\Admin\My Documents\VB.NET\Stock delna\STC.sql ). plz help me
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
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
pls provide steps to connect mysql database in flex - XML
pls provide steps to connect mysql database in flex  hi,i am new to flex and doing project. i have doubt in how to connect MYSQL database in flex .pls provide the steps . i would be really thankful 2 u. i am loooking
Connect to the database
Connect to the database  how to connect to the database in the iphone
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
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
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
Connect from database using JSP Bean file
Connect from database using JSP Bean file... to the MySQL database and then we have made the properties setter and getter...="sample" class="myexample.bean" scope="page">    <jsp
pls provide steps to connect mysql database in flex - XML
pls provide steps to connect mysql database in flex  hi, pls provide steps to connect mysql database in flex.pls i am trying from last week still it was not connected .pls provide the step by step procedure.i am looking
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
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
Using Network Address To Connect to a Database
to connect a MySql database with your application over a network then you must load... is "root" An example of using network address to connect to database... no of that database. The default port no of MySql database is 3306 and default host
 

 

 

DMCA.com