Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class prog2_11
- {
- public static void main(String[] args)
- {
- // TODO Auto-generated method stub
- Connection connect;
- try
- {
- String driverName = "com.mysql.jdbc.Driver";
- Class.forName(driverName);
- String serverName = "localhost";
- String mybase = "base00";
- String url_="jdbc:mysql://" + serverName + "/" + mybase;
- String userName = "root";
- String password = "";
- connect = DriverManager.getConnection(url_, userName, password);
- String query = "SELECT * FROM tab00";
- Statement stmt = connect.createStatement();
- ResultSet rs = stmt.executeQuery(query);
- String temp;
- while(rs.next())
- {
- temp = rs.getString("name");
- System.out.println(temp);
- }
- connect.close();
- }
- catch (Exception e)
- {
- // TODO: handle exception
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement