วันอาทิตย์ที่ 29 พฤศจิกายน พ.ศ. 2558

การเขียนโปรแกรมใช้งานอย่างง่าย



ตัวอย่างแฟ้ม a.jsp ที่สร้างขึ้นด้วย notepad
<body><pre>
<%
for (int i=1;i<=10;i++)
{
 out.println(i);
}
%>
</pre></body>

ตัวอย่างแฟ้ม b.jsp :: อ่านข้อมูลจาก DSN ใน ODBC มาแสดงผล
<body>
<%@ page import="java.sql.*" %>
<%
  Connection connection;
  Statement statement;
  String sourceURL = "jdbc:odbc:empl";
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  connection = DriverManager.getConnection(sourceURL);
  statement = connection.createStatement();
  String sql = "select * from empl";
  ResultSet myresult = statement.executeQuery(sql);
  while (myresult.next()) {
    out.println(myresult.getString("emplid") + "<br>");
  }    
  myresult.close();
%>
</body>


ไม่มีความคิดเห็น:

แสดงความคิดเห็น