title: Checking database connectivity in JSP
body: <p>How can I check the database connectivity in JSP. I want to print an error message if there is any problem occurs with the database connectivity. </p>
  
  <p>I m using the following code:</p>
  
  <pre><code>Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  String connectionUrl = "jdbc:sqlserver://localhost;databaseName=dbname;user=username;password=password";
  Connection conn = DriverManager.getConnection(connectionUrl); 
  Statement stmt = conn.createStatement();
  </code></pre>
  
  <p>After successfull connection, I want to insert data to the database. I also want to check the whether the data is inserted properly. Can anyoone help me on this...</p>