How to connect Java Eclipse to MySQL Server?

JDBC connectivity to MySQL Server

Steps:

1.Download MySQL JDBC Driver from http://dev.mysql.com/downloads/connector/j/



2.  After downloading the zip file, extract it and add this .rar file to lib folder of eclipse project.
  learn how to add .rar file to the eclipse folder by following the steps(1-5) from this post.
http://sunysudan.blogspot.com/2017/05/how-to-find-similarity-between-two.html


3.Make a class file and paste the following code.

import java.sql.*;
//import the all valuable stuffs frm SQL

public class driver {

public static void main(String[] args) {
// TODO Auto-generated method stub
try{

//Get connection
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/new","root","root");
// here , new is the name of database that i created from MySQL Workbench, first root is my username of sql server and second root is my password. 
// make statement
Statement st=con.createStatement();
//execute sql query
ResultSet rs=st.executeQuery("select * from new_table");
// new_table is the name of my table that i have created from the MySQL Server Workbench.
//process result set
while(rs.next())
{
System.out.println(rs.getString("name"));
// name is the column name of my table.
}
}catch( Exception exc){
exc.printStackTrace();
}
}

}




How to find the similarity between two words in java using wordnet? 




Comments

Popular posts from this blog

Accounting Multiple Choice Questions with answers | Download PDF for MCQs

Accounting Multiple Choice Questions with answers | Download PDF for MCQs