Guest User

Untitled

a guest
May 26th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. String mmobile = mobile;
  2. //Prepare Url
  3. URLConnection myURLConnection=null;
  4. URL myURL=null;
  5. BufferedReader reader=null;
  6.  
  7. String mainUrl="http://localhost:8080/Portal/example.jsp?";
  8. //Prepare parameter string
  9. StringBuilder sbPostData= new StringBuilder(mainUrl);
  10.  
  11. sbPostData.append("mobile=").append(mmobile);
  12.  
  13. //final string
  14. mainUrl = sbPostData.toString();
  15. try
  16. {
  17. //prepare connection
  18. myURL = new URL(mainUrl);
  19. myURLConnection = myURL.openConnection();
  20. myURLConnection.connect();
  21.  
  22. }
  23. catch (IOException e)
  24.  
  25. <%@page import="java.sql.*"
  26. %>
  27. <%@ page import="myclass.SAMPLE" %>
  28.  
  29. <%
  30. Class.forName("com.mysql.jdbc.Driver").newInstance();
  31. Connection conn = null;
  32. String mphone = request.getParameter("mobile");
  33.  
  34. int mcompregkeyid=0;
  35. try {
  36. conn = DriverManager.getConnection("jdbc:mysql://localhost/myschema","myuser","mypass");
  37. Statement stmt = conn.createStatement();
  38. ResultSet rset = stmt.executeQuery("Select max(keyid) from mytable");
  39. rset.next();
  40. mcompregkeyid=rset.getInt(1);
  41.  
  42. } finally {
  43. if (conn != null) try { conn.close(); } catch (SQLException e) {
  44. out.println("("Could not connect to local server.nPlease try after some time.!!!")");
  45. }
  46. }
  47. SAMPLE.getValue(String.valueOf(mcompregkeyid));
  48.  
  49. %>
Add Comment
Please, Sign In to add comment