Documente Academic
Documente Profesional
Documente Cultură
To connect Java application with the MySQL database, we need to follow 5 following steps.
In this example we are using MySql as the database. So we need to know following informations
for the mysql database:
1. Driver class: The driver class for the mysql database is com.mysql.jdbc.Driver.
2. Connection URL: The connection URL for the mysql database is
jdbc:mysql://localhost:3306/sonoo where jdbc is the API, mysql is the database,
localhost is the server name on which mysql is running, we may also use IP address, 3306
is the port number and sonoo is the database name. We may use any database, in such
case, we need to replace the sonoo with our database name.
3. Username: The default username for the mysql database is root.
4. Password: It is the password given by the user at the time of installing the mysql
database. In this example, we are going to use root as the password.
Let's first create a table in the mysql database, but before creating table, we need to create
database first.
use sonoo;
In this example, sonoo is the database name, root is the username and password both.
download the jar file mysql-connector
https://static.javatpoint.com/src/jdbc/mysql-connector.jar
So, which databases are most popular in 2019? Knowing that SQL was used by over 3/5 of
respondents, you might assume Oracle stole the show. Guess again. MySQL dominated this
report with 38.9% use, followed by MongoDB at 24.6%, PostgreSQL at 17.4%, Redis at 8.4%, and
Cassandra at 3.0%. Oracle trailed behind at just 1.8% from these database reporters, and
CouchDB, Berkeley DB, Microsoft SQL Server, Redshift, Firebase, Elasticsearch, and InfluxDB
users combined our Other category at 2.4%.
While these numbers might shock, there’s no mistaking the rise in popularity of MySQL,
MongoDB, and PostgreSQL. So how does this survey compare to best-known source for
database management system trends? DB-Engines Ranking – Trend Popularity report places
these leaders in the top 5, but Oracle keeps hold at number one and Microsoft SQL Server at
number 3.
Create Procedure
Following statements create a stored procedure. By default, a procedure is associated with the default
database (currently used database). To associate the procedure with a given database, specify the name
as database_name.stored_procedure_name when you create it. Here is the complete syntax :
import java.sql.*;
class MysqlCon {
https://www.java67.com/2015/07/difference-between-type-1-2-3-and-4-jdbc-drivers-java.html