Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
- public class Mein {
- public static void main(String[] args) {
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- Connection conexion = DriverManager.getConnection
- ("jdbc:mysql://localhost/Mia", "root", "Namdi.31");
- Statement s = conexion.createStatement();
- // s.executeQuery ("INSERT INTO usuarios VALUES('saul','123'); ");
- PreparedStatement a =null;
- a= conexion.prepareStatement("INSERT INTO usuarios VALUES('saul','123'); ");
- a.executeUpdate();
- ResultSet rs = s.executeQuery ("SELECT * FROM usuarios ");
- while (rs.next())
- {
- System.out.println (rs.getString (1) + " " + rs.getString (2));
- }
- }
- catch (Exception e){
- e.printStackTrace();
- System.out.println("ERROR");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement