Advertisement
Guest User

Untitled

a guest
Feb 26th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. .
  2. └── myapp
  3. ├── META-INF
  4. │   └── MANIFEST.MF
  5. └── WEB-INF
  6. ├── classes
  7. │   └── src
  8. │   └── MyMainServlet.class
  9. ├── lib
  10. │   ├── mysql-connector-java-5.1.35-bin.jar
  11. │   └── servlet-api.jar
  12. └── web.xml
  13.  
  14. package src;
  15.  
  16. import java.io.IOException;
  17.  
  18. import javax.servlet.ServletException;
  19. import javax.servlet.http.HttpServlet;
  20. import javax.servlet.http.HttpServletRequest;
  21. import javax.servlet.http.HttpServletResponse;
  22.  
  23. import java.sql.Connection;
  24. import java.sql.DriverManager;
  25. import java.sql.ResultSet;
  26. import java.sql.SQLException;
  27. import java.sql.Statement;
  28.  
  29. import java.util.ArrayList;
  30.  
  31.  
  32. // @url-pattern = "/mymain";
  33. public class MyMainServlet extends HttpServlet
  34. {
  35. public void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
  36. {
  37. //someMethod();
  38. System.out.println( "Hello World!!!" );
  39. }
  40.  
  41.  
  42. public void someMethod()
  43. {
  44. String s_sql = "";
  45. Connection con = null;
  46. Statement stm = null;
  47.  
  48. try
  49. {
  50. con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/somebd", "root", "root123456" );
  51. stm = con.createStatement();
  52. stm.executeUpdate( s_sql );
  53. }
  54. catch( SQLException sqle ) { sqle.printStackTrace(); }
  55. finally
  56. {
  57. try { con.close(); } catch(SQLException se) { /* ... */ }
  58. try { stm.close(); } catch(SQLException se) { /* ... */ }
  59. }
  60. }
  61. }
  62.  
  63. java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/somebd
  64.  
  65. Manifest-Version: 1.0
  66. Created-By: 1.8.0_72 (Oracle Corporation)
  67. Main-Class: src.MyMainServlet
  68. Class-Path: ./mysql-connector-java-5.1.35-bin.jar ./servlet-api.jar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement