Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.DriverManager;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class conexao {
- public static void main(String[] args)
- {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/t2ti";
- Connection con = DriverManager.getConnection(url,"root","h2vc2304");
- System.out.println("con: "+con);
- Statement Statement = con.createStatement();
- //Statement.executeUpdate("Insert into clietes (rg,nome) values (4,'fulano')");
- ResultSet rs = Statement.executeQuery("Select * from clietes");
- if(rs.first())
- {
- do
- {
- System.out.println("Nome: "+rs.getString("nome"));
- }while(rs.next());
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement