KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > databaseclassloader > addon > vendor > util


1 // simple test file
2
package org.apache.derbyTesting.databaseclassloader.addon.vendor;
3
4
5 import java.sql.*;
6
7 public class util
8 {
9
10   public static short valid(String JavaDoc contact)
11     throws SQLException
12   {
13        Connection conn = DriverManager.getConnection("jdbc:default:connection");
14        PreparedStatement ps = conn.prepareStatement(
15          "SELECT OK FROM EMC.CONTACTS WHERE E_MAIL = ?");
16
17        ps.setString(1, contact);
18
19        short ok = 0;
20
21        ResultSet rs = ps.executeQuery();
22
23        if (rs.next())
24        {
25          if (rs.getShort(1) == 1)
26             ok = 1;
27        }
28
29        rs.close();
30        ps.close();
31        conn.close();
32        return ok;
33   }
34 }
35
Popular Tags