0
<%@ page language="java" import="java.sql.*" errorPage="" %>

<%
Connection conn = null;
        
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
conn = DriverManager.getConnection("jdbc:odbc:mydsn","a", "a");
        
PreparedStatement psInsertRecord=null;
String sqlInsertRecord=null;






String dt=request.getParameter("datum1");

String Name=request.getParameter("Name");

try
  {
sqlInsertRecord="insert into ATT (Date, Name) values(?,?)"; 
psInsertRecord=conn.prepareStatement(sqlInsertRecord);

psInsertRecord.setString(1,dt);
psInsertRecord.setString(2,Name);

psInsertRecord.executeUpdate();
}


catch(Exception e)
{
out.println("Unable to connect to the database");
}

   try{
      if(psInsertRecord!=null)
      {
       psInsertRecord.close();
      }
      
      if(conn!=null)
      {
       conn.close();
      }
    }
    catch(Exception e)
    {
      e.printStackTrace(); 
    }

	%>


</head>
<body>
<h3><center>Data saved successfully.<center><h3>
</body>
</html>


I am getting the following output:"Unable to connect to the database"
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Stefano Mtangoo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.