Database quering? [message #375201] |
Fri, 03 August 2001 11:12 |
Adebayo
Messages: 5 Registered: August 2001
|
Junior Member |
|
|
The code works but I do not know how to display the data in browser using forms
<%
try
{
//loading the drivers
//this code loads JDBD-ODBC Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//making connection
//The second step in establishing a connection is to have the appropriate
//driver connect to the DBMS. The following line of code illustrates the
//general idea:
String url="jdbc:odbc:/test/adetest/make_coffee";
//where "test" is the system dsn name
Connection con=DriverManager.getConnection(url, "administrator", "password");
//where "administrator is the username to
//access the database and password is " password"
//DriverManager's getconnection method estabilishes connection
//with the database specified in the JDBC URL
//Then create jdbc statement
Statement stmt = con.createStatement();
String query="select FIRST, LAST from ADEBAYO.EMPLOYEE where FIRST ='Luke'";
//Execute the statement
stmt.executeUpdate(query);
}
catch (Exception e) {
out.println("table coffees NOT created");
}
//give confirmation message
out.println("table coffees created");
%>
|
|
|