Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ConnectMySQL;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- /**
- *
- * @author ACER
- */
- public class mysql {
- public static void main(String[] args) {
- Connection con;
- Statement st;
- ResultSet rs;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "12345678");
- System.out.println("You are welcome !");
- st = con.createStatement();
- String sql = "Select * from DIC";
- rs = st.executeQuery(sql);
- while(rs.next()){
- System.out.println(rs.getString("WORD"));
- }
- } catch (Exception ex) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement