Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package anketsitesi;
  7. import com.mysql.jdbc.Driver;
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.ResultSet;
  11. import java.sql.SQLException;
  12. import java.sql.Statement;
  13. /**
  14. *
  15. * @author mem
  16. */
  17. public class db {
  18. String url = "jdbc:mysql://localhost:3306/anket?useUnicode=true&characterEncoding=UTF-8";
  19. String kullaniciadi = "root";
  20. String sifre = "";
  21.  
  22. public Statement Baglan() throws SQLException {
  23. DriverManager.registerDriver(new Driver());
  24. Connection con=DriverManager.getConnection(url, kullaniciadi, sifre);
  25. Statement st=con.createStatement();
  26. return st;
  27.  
  28. }
  29.  
  30. public ResultSet sorgula(String query) throws SQLException {
  31. Statement st = this.Baglan();
  32.  
  33. ResultSet rs = st.executeQuery(query);
  34. return rs;
  35. }
  36. public void Kaydet(String query) throws SQLException{
  37. Statement s=this.Baglan();
  38. s.execute(query);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement