Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  2. throws ServletException, IOException {
  3. try {
  4. String driver = "com.mysql.jdbc.Driver";
  5. con = null;
  6. String username = "";
  7. String password = "";
  8.  
  9. Class.forName("com.mysql.jdbc.Driver").newInstance();
  10.  
  11. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbName", "root", "password");
  12. Statement st = con.createStatement();
  13. ResultSet mar = st.executeQuery("SELECT * FROM table");
  14.  
  15.  
  16. Gson gson = new GsonBuilder().create();
  17. response.setContentType("application/json");
  18. response.setCharacterEncoding("utf-8");
  19.  
  20. } catch (SQLException e) {
  21. String message = e.getMessage();
  22. }
  23.  
  24. java.sql.Driver d=new com.mysql.jdbc.Driver();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement