Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package week4;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class week4 {
- public static void main(String[] args) {
- try(Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/itb", "root", "Pass$$")){
- Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("Select * from dept");{
- while(rs.next()) {
- System.out.printf("%5d%14s%14s",
- rs.getInt("DEPTNO"),
- rs.getString("DNAME"),
- rs.getString("LOC"));
- }
- }
- System.out.println("Success!");
- }catch(SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement