mysql connectivity with Java
create database,use,create table in mysql
here mysql username is root and password is vp
You need mysql connectivity .jar driver so Download it from mysql website
mysql-connector-java-3.1.14-bin.jar
Add this .jar file in projects properties by Right click and Java Build path
Add External jars
here add mysql connector java 3.1.14-bin.jar by file browsing in Eclipse
look like this
This 2 lines are essential of mysql connectivity
create database,use,create table in mysql
here mysql username is root and password is vp
You need mysql connectivity .jar driver so Download it from mysql website
mysql-connector-java-3.1.14-bin.jar
Add this .jar file in projects properties by Right click and Java Build path
Add External jars
here add mysql connector java 3.1.14-bin.jar by file browsing in Eclipse
look like this
if
u use Netbeans
,do following 1.Open Netbeans IDE 2.Right-click your Project.
3.Select Properties. 4.On the left-hand side click Libraries. 5.Under
"Compile" tab - click Add Jar/Folder button. 6.Select Downloaded
"mysql-connector-java-5.1.25-bin.jar" file (Download Connector/J from
dev.mysql.com) 7.Click OK Run Again... Its work.
This 2 lines are essential of mysql connectivity
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dblogin","root","vp");
here mysql username is root and password is vp and dblogin is the name of Database and 3306 is port.
how to find user in mysql
just write query in mysql
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.41 sec)
How to find port in Mysql
just write select @port;
or
mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
here mysql username is root and password is vp and dblogin is the name of Database and 3306 is port.
how to find user in mysql
just write query in mysql
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.41 sec)
How to find port in Mysql
just write select @port;
or
mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)