Example 7 57   Authentication mechanism example
import java.lang.*;
import java.io.*;
import java.sql.*;
import java.net.*;
public class AccessControl
{
// in our example we use fixed values, you should make this variable
private static final String DB2DB  = "sample"; // database name
private static final String DB2USR = "itsosj"; // database user
private static final String DB2PWD = "itsosj"; // database password
private static Connection db2Conn; // DB2 connection object
   
public static void main(String[] args) throws SQLException, Exception
{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
db2Conn=DriverManager.getConnection("jdbc:db2:"+DB2DB,DB2USR,DB2PWD);
// This example shows how to verify accesss to specific functions
// depending on the host where the program is executed.
// We assume that this program runs locally and connects directly to DB2
// In a client/server app, the server must detect the client s host.
// Java provides two methods for this purpose:
//   socket.getInetAddress() ... for socket connections
//   request.getRemoteHost() ... for HTTP connections
// In this example the username is the same as the DB2 user.
// The application user and the database user could also be different.
// This example implements no error handling.
// This example shows access to two specific functions:
//
SELECT...this is indicated by mode='SEL'
//
INSERT...this is indicated by mode='INS'
// mode should be a variable parameter
String mode = "SEL";
InetAddress addr = InetAddress.getLocalHost(); // appl executes locally
String ipname = addr.getHostName();            // get the hostname
String ipaddr = addr.getHostAddress();         // get the ip address
System.out.println("Host name = " + ipname); 
System.out.println("Host addr = " + ipaddr); 
224 
MySQL to DB2 UDB Conversion Guide






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved