Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.jdbc.test;
- import sun.tools.java.ClassNotFound;
- import java.sql.*;
- public class test {
- public static void main (String[] args) {
- String URL="jdbc:mysql://localhost:3306/new_schema";
- String USERNAME="d";
- String PASSWORD="Q1w2e3r4t5y6&";
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
- Statement statement = connection.createStatement();
- ResultSet resultSet=statement.executeQuery("SELECT * FROM employee");
- while (resultSet.next()){
- System.out.println(resultSet.getString(2));
- }
- resultSet.close();
- statement.close();
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- } catch ( ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment