Advertisement
Guest User

mysql

a guest
May 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
  2. import java.sql.Connection;
  3. import java.sql.ResultSet;
  4. import java.sql.Statement;
  5.  
  6. public class Test {
  7.  
  8. static MysqlDataSource mds = new
  9. MysqlDataSource();
  10.  
  11.  
  12. public static void main(String[] args) {
  13.  
  14. try{mds.setURL(
  15. "jdbc:mysql://localhost/bibliothek");
  16. mds.setUser ("root");
  17.  
  18. Connection con = mds.getConnection();
  19.  
  20. Statement stm = con.createStatement();
  21.  
  22. stm.execute("select * from buch");
  23.  
  24. ResultSet rs = stm.getResultSet();
  25.  
  26. if ( rs != null)
  27.  
  28. } catch(Exception ex) {
  29. ex.printStackTrace();
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement