Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Using MYSQL Database with JSP & Servlets.

Using MYSQL Database with JSP & Servlets. Using MYSQL Database with JSP & Servlets. MY SQL is a powerful RDBMS, which can handle large amount of data. And more interestingly it is free to use, except for some commercial use. you can download it

Tutorial Details:

from www.mysql.com . It is available for both Linux and NT platforms, but it is primarily for Linux and Unix servers and is mostly used on Linux and Unix platform.
This lesson is intended to provide hands an experience with MYSQL database. We will use tomcat web server to run over web application which acceres the MYSQL database. Here I am using MYSQL & tomcat server both running an Linux machine.
Downloading and installing MYSQL Server.
Downloading MYSQL server from www.mysql.com . Upload the downloaded file on to your Linux server. go to the directory where you uploaded the file. To install the file issue the Following command.
rpm-ivh mysql-server-3.23.361.1386.rpm.
This will install the MySQL server on your Linux machine.
Testing the installation is complete.
Issue the following command after the installation is complete.
MYSQL
And you will see the mysql prompt (mysql>) appears ,this means that you sucessfully installed mysql on your Linux server.
Syntax is:
mysql -h hostname -u username -p[password]
Or
mysql -h hostname -u username --password=password
Typing help on the mysql prompt shows online help.
mysql> help
MySQL commands:
help (\h) Display this text
? (\h) Synonym for `help'
clear (\c) Clear command
connect (\r) Reconnect to the server. Optional arguments are db and host
edit (\e) Edit command with $EDITOR
exit (\q) Exit mysql. Same as quit
go (\g) Send command to mysql server
ego (\G) Send command to mysql server; Display result vertically
print (\p) Print current command
quit (\q) Quit mysql
rehash (\#) Rebuild completion hash
status (\s) Get status information from the server
use (\u) Use another database. Takes database name as argument
Connection id: 1 (Can be used with mysqladmin kill)
mysql>
Creating a Database.
Now we create a database named "mysqltutorial" for our tutorial. create database is used to create database. Issue the following command to create mysqltutorial database.
mysql> create database mysqltutorial;
Query OK, 1 row affected (0.18 sec)
mysql>
After creating database it is required to connect to the database to create tables for our tutorial. To connect to a database "use " command is used. Type the following command to connect to mysqltutorial database.
mysql> use mysqltutorial;
Database changed
mysql>
In MySQL all the database commands are followed by a semi-colon(;).
Now we will create a table in the database 'test' for storing the names of countries. " Create table " command is used to create the table. Issue the following command on mysql promopt:
mysql> create table test(srno int, countryname char(50));
Query OK, 0 rows affected (0.29 sec)
mysql>
In the above example we have created a table named "test" to store country name, but the name "test" is not good. So we will change the name of table to "country". We will use " rename" command to rename the table. Type the following command to rename the table:
mysql> alter table test RENAME countryname;
Query OK, 0 rows affected (0.04 sec)
To view structure of database "desc
" is used. To view structure of countryname issue the following command:
mysql> desc countryname;
Above command renames the table. To insert some records in the database insert into table (fields..) values (values..) command is used. Issue the following command to enter the country name in the database.
mysql> insert into countryname(srno,countryname) values(1,'India');
Query OK, 1 row affected (0.09 sec)
mysql>
mysql> insert into countryname(srno,countryname) values(2,'USA');
Query OK, 1 row affected (0.09 sec)
mysql>
Above command enters a record in the countryname table. To view records from the countryname table issue the following command:
mysql> select * from countryname;
In this section you learned how to work with MySQL database server, create database, create tables in database, rename table and insert and select the records from database table. In the next lesson we will learn how to connect to the database from JSP page.
Send you queries/suggestions regarding this tutorial to Deepak Kumar .


 

Rate Tutorial:
http://www.roseindia.net/mysql/mysql.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Using MYSQL Database with JSP & Servlets.

View Tutorial:
Using MYSQL Database with JSP & Servlets.

Related Tutorials:

Which JSP book serves up the best lesson?
Which JSP bookAs for Web servers/databases, just mentioning a server in the book is not sufficient to be listed here.
 
Using CachedRowSet to Transfer JDBC Query Results Between Classes
Using CachedRowSet to Transfer JDBC Query Results Between Classes The Java Database Connectivity (JDBC) API provides developers with an interface to a SQL database server, such as MySQL or Oracle. Central to any JDBC application is the java.sql.ResultS
 
Jeff Schmitt's JDBC Page
This tutorial assumes you are using the MySQL database and the GWE JDBC drivers. The host computer is triton.towson.edu.
 
Introduction to JSP
Introduction to JSP Introduction to JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database driven web applications. JSP enable the
 
Advanced form processing using JSP
Processing HTML forms using servlets, or more often, CGI scripts, is one of the most common operations performed on the Web today. However, that JavaServer Pages (JSPs) can play a significant role in sophisticated form processing is a little-known secret.
 
Backing Up and Restoring A MySQL Database
Backing Up and Restoring A MySQL Database Backing Up and Restoring A MySQL Database This tutorial explains the how to backup and restore the MySQL Database. Databases are used to store large amount of precious data and it becomes very important to
 
Welcome to Java Developers paradise!
Welcome to Java Developers paradise! T his site contains many quality Java, JSP, RMI, MySQL downloads, tutorials, source codes and links to other java resources. We have large number of links to the tutorials on java which will help you learn java
 
Free JSP, Free EJB and Free Servlets Hosting Servers
Free JSP, Free EJB and Free Servlets Hosting Servers Free JSP, Free EJB and Free Servlets Hosting Servers Web roseindia.net Other Free Hosting Services MyCGIserver - Free Hosting server provides the following support with the free account: JSP
 
Free JSP, Free EJB and Free Servlets Hosting Servers
Free JSP, Free EJB and Free Servlets Hosting Servers Web roseindia.net Free JSP, Free EJB and Free Servlets Hosting Servers MyCGIserver - Free Hosting server provides the following support with the free account: JSP 1.1, Servlets, Apache Cocoon,
 
First Step towards JDBC!
First Step towards JDBC! First Step towards JDBC Introduction T his article introduce you with JDBC and shows you how to create a database application to access the databases. For the shake of simplicity, in very first example Access database and
 
First Step towards JDBC!
First Step towards JDBC! Welcome to our JDBC Section First Step towards JDBC This article introduce you with JDBC and shows you how to create a database application to access the databases. Accessing the Database from Servlet This article shows
 
Accessing Database from servlets through JDBC!
Accessing Database from servlets through JDBC! Accessing Access Database From Servlet T his article shows you how to access database from servlets. Here I am assuming that you are using win95/98/2000 and running Java Web Server. For the sake of
 
Introduction to the JSP Java Server Pages
Introduction to the JSP Java Server Pages Welcome to JSP Section Introduction To JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database
 
JSP FUNDAMENTALS
JSP FUNDAMENTALS JSP FUNDAMENTALS By: Hrishikesh Deshpande Introduction : JSP termed as Java Server Pages is a technology introduced by Sun Microsystems Inc. to develop the web application in more efficient way than Servlets. It has got many
 
Welcome to the MySQL Tutorials
Welcome to the MySQL Tutorials Welcome to the MySQL Tutorials Using MYSQL Database This lesson is intended to provide hands an experience with MYSQL database Backing Up and Restoring A MySQL Database In this lession you will learn how to take
 
Using MYSQL Database with JSP & Servlets.
Using MYSQL Database with JSP & Servlets. Using MYSQL Database with JSP & Servlets. MY SQL is a powerful RDBMS, which can handle large amount of data. And more interestingly it is free to use, except for some commercial use. you can download it
 
Connecting to MySQL database and retrieving and displaying data in JSP page
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 from the
 
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database Using JDBC and Pure Java driver Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver for connecting our application to the database. MM.MySQL Driver is
 
Download Search Engine Code its free and Search engine is developed in Servlets
Download Search Engine Code its free and Search engine is developed in Servlets Download Search Engine Code Installation Instruction Download and unzip the file into your favorite directory. Create a database on your MySQL Server. Run all the
 
Building Search Engine Applications Using Servlets !
Building Search Engine Applications Using Servlets ! Building Search Engine Applications Using Servlets Please visit http://www.webappcabaret.com/javadevelopers/search to see running copy of our search engine. Introduction This tutorial takes
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.