Advertisement
Guest User

Untitled

a guest
Feb 26th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 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. public class MyMainServlet extends HttpServlet
  33. {
  34. public void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
  35. {
  36. //someMethod();
  37. System.out.println( "Hello World!!!" );
  38. }
  39.  
  40.  
  41. public void someMethod()
  42. {
  43. String s_sql = "";
  44. Connection con = null;
  45. Statement stm = null;
  46.  
  47. try
  48. {
  49. con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/somebd", "root", "root123456" );
  50. stm = con.createStatement();
  51. stm.executeUpdate( s_sql );
  52. }
  53. catch( SQLException sqle ) { sqle.printStackTrace(); }
  54. finally
  55. {
  56. try { con.close(); } catch(SQLException se) { /* ... */ }
  57. try { stm.close(); } catch(SQLException se) { /* ... */ }
  58. }
  59. }
  60. }
  61.  
  62. java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/somebd
  63.  
  64. Manifest-Version: 1.0
  65. Created-By: 1.8.0_72 (Oracle Corporation)
  66. Main-Class: src.MyMainServlet
  67. Class-Path: ./mysql-connector-java-5.1.35-bin.jar ./servlet-api.jar
  68.  
  69. Class.forName("com.mysql.jdbc.Driver")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement