Guest User

Database through eclipse

a guest
Apr 18th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package guii;
  2. import java.sql.*;
  3. public class guiii {
  4. private String query;
  5. private Connection conn;
  6. private Statement stat;
  7. private ResultSet re;
  8. private PreparedStatement pr;
  9. guiii(){
  10. conn=null;
  11. stat=null;
  12. re=null;
  13. pr=null;
  14.  
  15. }
  16. public void run() throws ClassNotFoundException, SQLException{
  17. Class.forName("com.mysql.jdbc.Driver");
  18. conn=DriverManager.getConnection("jdbc:mysql://localhost/lab?user=root");
  19. stat=conn.createStatement();
  20. query="create table employee(id int(25) Primary key, name varchar(25))";
  21. stat.executeUpdate(query);
  22. }
  23. public static void main(String args[]) throws ClassNotFoundException, SQLException{
  24. guiii t=new guiii();
  25. t.run();
  26.  
  27. }
  28.  
  29.  
  30. }
Add Comment
Please, Sign In to add comment