This discussion is archived
6 Replies Latest reply: May 7, 2012 9:54 AM by 935143 RSS

How to connect to database from applet

929625 Newbie
Currently Being Moderated
HI ...
plz hlep me....
I'm having an applet where we should display the database values in the applet...
It works fine in the local system(same network)...
but when its in the server, we r getting null values in the local system..
I created a policy file and also added that url in java.security but came error below(different network)...

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:273)
     at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:327)
     at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:360)
     at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:150)
     at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)
     at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
     at java.sql.DriverManager.getConnection(Unknown Source)
     at java.sql.DriverManager.getConnection(Unknown Source)
     at QueryBuilderApplet$1.run(QueryBuilderApplet.java:132)
     at java.awt.event.InvocationEvent.dispatch(Unknown Source)
     at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
     at java.awt.EventQueue.access$000(Unknown Source)
     at java.awt.EventQueue$3.run(Unknown Source)
     at java.awt.EventQueue$3.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)


my applet code is :


import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.awt.Cursor;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

//Imports for getDataClass
import java.sql.*;
import sun.jdbc.odbc.JdbcOdbcDriver;

import javax.swing.JApplet;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;

import netscape.javascript.JSObject;
import netscape.javascript.JSException;

import com.adbs.metadata.JdbcMetadataProvider;
import com.adbs.querybuilder.Parameter;
import com.adbs.querybuilder.ParameterList;
import com.adbs.querybuilder.PlainTextSQLBuilder;
import com.adbs.querybuilder.QueryBuilderException;
import com.adbs.querybuilder.SQLUpdatedEvent;
import com.adbs.querybuilder.SQLUpdatedEventListener;
import com.adbs.syntax.AutoSyntaxProvider;
import com.adbs.syntax.DB2SyntaxProvider;
import com.adbs.syntax.MSSQLSyntaxProvider;
import com.adbs.syntax.MySQLSyntaxProvider;
import com.adbs.syntax.OracleSyntaxProvider;
import com.adbs.syntax.PostgreSQLSyntaxProvider;
import com.adbs.syntax.SybaseSyntaxProvider;
//import com.google.gwt.user.client.ui.MouseListener;
import com.adbs.syntax.UniversalSyntaxProvider;

public class QueryBuilderApplet extends JApplet {
     
     private JSObject win;
     private String connServer;
     private String connName;
     private String query;
     private String connId;
     private String le;
     private String repoName;

     private String connUrl;
     private String driver;
     private String userName;
     private String passWord;
     private com.adbs.querybuilder.QueryBuilder queryBuilder1;
     private JdbcMetadataProvider metadataProvider = new JdbcMetadataProvider();
private static final long serialVersionUID = 1L;

private PlainTextSQLBuilder plainTextSQLBuilder1 = new PlainTextSQLBuilder();

private String list;


     public String getQuery(){
          list="No-List";
                    list = queryBuilder1.getSQL();
          return list;
     }
     
     @Override
     
     
     public void init() {
          System.out.println(">>>>>>>>>>>> init() >>>>>>");
          connServer = getParameter("type");
          connName = getParameter("name");
          query = getParameter("qry");
          connId = getParameter("connId");
          le = getParameter("le");
          repoName =getParameter("repoName");
          win = JSObject.getWindow(this);
          final StringBuffer metaData = new StringBuffer();     
          metaData.append(getMetadataFileObject( connServer, connName));
          final HashMap hsp = getConnParameters (repoName, le, connId);
     connUrl = (String) hsp.get("setURL");
     driver = (String)hsp.get("setDriver");
     userName = (String)hsp.get("setUserName");
     passWord = (String)hsp.get("setPassword");
     
     try
               {
     java.awt.EventQueue.invokeAndWait(new Runnable()
                    {
     public void run()
                         {
                              // set native Look'n'Feel
                              try
                              {
                                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                              }
                              catch (Exception ex)
                              {
                                   System.out.println(ex.getMessage());
                              }
                              
                              //init();
                              initComponents();
                              
                              if ("oracle".equalsIgnoreCase(connServer))
                    {
                              
                         try{
                         Class.forName(driver).newInstance();
                         }catch(Exception e){
                         }try{     
                         metadataProvider.setConnection(DriverManager.getConnection(connUrl, userName,passWord));
                    } catch (SQLException e) {
                         e.printStackTrace();
                    }
                    queryBuilder1.setMetadataProvider(metadataProvider);
                         OracleSyntaxProvider syntaxProvider = new OracleSyntaxProvider();
                    queryBuilder1.setSyntaxProvider(syntaxProvider);
                    
                         
                    }
                              //set up SQL builder:
                              plainTextSQLBuilder1.setQueryBuilder(queryBuilder1);
                              
                              // handle the notification from plainTextSQLBuilder1 about the query text has been changed
                              plainTextSQLBuilder1.addSQLUpdatedEventListener(new SQLUpdatedEventListener()
                              {
                                   @Override
                                   public void sqlUpdatedEventOccurred(SQLUpdatedEvent event)
                                   {
                                        try
                                        {
                                             jTextPane1.setText(plainTextSQLBuilder1.getSQL());
                                        }
                                        catch (QueryBuilderException ex)
                                        {
                                             JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                                        }
                                   }
                              });

                              // Load metadata from XML file located in resources (for demonstration purposes)
                              try
                              {
                                   queryBuilder1.getMetadataContainer().loadFromXML(metaData.toString()); //sb.toString()
                                   
                                   System.out.println("applet @176 : Write successfully.......");
                              
                              }
                              catch (Exception ex)
                              {
                                   Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                                   JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                              }
     if (!("".equals(query))){
                                   try
                                   {
                                        queryBuilder1.setSQL(query);
                                   }
                                   catch (QueryBuilderException ex)
                                   {
                                        JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                                   }
                         }
                              // force the jTextPane1 to move the focus on the Tab key:
          KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
                              HashSet keystrokes = new HashSet();
                              keystrokes.add(tab);
                              jTextPane1.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keystrokes);

                              KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK);
                              keystrokes = new HashSet();
                              keystrokes.add(shiftTab);
                              jTextPane1.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keystrokes);
     }
     });
     }
               catch (Exception ex)
               {
     ex.printStackTrace();
     }
               
     }

     public String getMetadataFileObject (String connServer, String connName)
     {
          System.out.println(">>>>>>>>>>>> getMetadataFileObject() >>>>>>");
          System.out.println("connServer "+connServer+" cccName "+connName);
     Vector classObj = new Vector();
     String result="";
     try {
          
     InputStream urlInput =null;
                    HttpURLConnection con =null;
                    
                    URL uri=new URL(getCodeBase(),"GetMetaDataFile?CONN_TYPE="+URLEncoder.encode(connServer)+"&CONN_NAME="+URLEncoder.encode(connName));
                    
                    con =(HttpURLConnection)uri.openConnection();
                    con.setDoInput(true);
                    con.setDoOutput(true);
                    con.setUseCaches(false);
                    con.setRequestMethod("POST");
                    con.setRequestProperty("Accept-Language", "en");
                    con.setRequestProperty("content-type", "text/html");
                    urlInput=con.getInputStream();
                    ObjectInputStream ois=new ObjectInputStream(urlInput);
                    Object obj= ois.readObject();
                    
                    String fileStr = (String)obj;
                    /*
                    File fname = new File("C:"+File.separator+"ice_store"+File.separator+"data"+File.separator+"metadata");
                    if (!fname.exists()){
                         //System.out.println("CREatingggggggggggggggggggggg:::::::::::::::::::::::::");
                         fname.mkdirs();
                    }     
                    String fileName = fname+File.separator+connName+".xml";
                    byte[] fileStream = fileStr.getBytes();
                    FileOutputStream fos = new FileOutputStream(fileName);

                    fos.write(fileStream);
                    fos.flush();
                    fos.close();
                    */
                    result = fileStr;
                    System.out.println("Received MetaData conetent displaying...");
                    urlInput.close();
     } catch (Exception e)
     {
     e.printStackTrace();
     }
     
     return result;
     }
     
          private void FillTableFromResultSet(final ResultSet resultSet)
          {
               try
               {
                    ResultSetMetaData metaData = resultSet.getMetaData();

                    int columnCount = metaData.getColumnCount();

                    Vector columns = new Vector(columnCount);

                    //store column names
                    for (int i = 1; i <= columnCount; i++)
                    {
                         columns.add(metaData.getColumnName(i));
                    }

                    Vector data = new Vector();
                    Vector row;

                    //store row data
                    while (resultSet.next())
                    {
                         row = new Vector(columnCount);

                         for (int i = 1; i <= columnCount; i++)
                         {
                              row.add(resultSet.getString(i));
                         }

                         data.add(row);
                    }

                    jTable1.setModel(new DefaultTableModel(data, columns));
               }
               catch (SQLException ex)
               {
                    Logger.getLogger(QueryBuilderApplet.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(this, ex.getMessage());
               }
          }
     
     @SuppressWarnings("unchecked")
     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
     
     private void initComponents() {

jTabbedPane1 = new javax.swing.JTabbedPane();
jSplitPane1 = new javax.swing.JSplitPane();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
queryBuilder1 = new com.adbs.querybuilder.QueryBuilder();
dataPanel = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
jButtonSave = new javax.swing.JButton();
jButtonCancel = new javax.swing.JButton();

setStub(null);

jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
     
jTabbedPane1StateChanged(evt);
}
});

jSplitPane1.setDividerLocation(450);
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane1.setResizeWeight(1.0);
jSplitPane1.setRightComponent(jScrollPane1);
jSplitPane1.setLeftComponent(queryBuilder1);
jSplitPane1.setRightComponent(jScrollPane1);

jTextPane1.setFont(new java.awt.Font("Monospaced", 0, 12));
jTextPane1.setDropTarget(null);
jTextPane1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {

     jTextPane1FocusLost(evt);
}
});
jScrollPane1.setViewportView(jTextPane1);

getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);

jTabbedPane1.addTab("SQL", jSplitPane1);

dataPanel.setLayout(new javax.swing.BoxLayout(dataPanel, javax.swing.BoxLayout.LINE_AXIS));

jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(jTable1);

dataPanel.add(jScrollPane2);

jTabbedPane1.addTab("Data", dataPanel);
getContentPane().add(jTabbedPane1);

jButtonSave.setText("SAVE");
jButtonSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSaveActionPerformed(evt);
}
});


jButtonCancel.setText("CANCEL");
jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
evt.setSource(query);
jButtonCancelActionPerformed(evt);
}
});

javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(panel1Layout);
panel1Layout.setHorizontalGroup(
panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
.addContainerGap(1025, Short.MAX_VALUE)
.addComponent(jButtonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonCancel)
.addGap(18, 18, 18))
);
panel1Layout.setVerticalGroup(
panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonSave)
.addComponent(jButtonCancel))
);
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

}
     


     private void jTextPane1FocusLost(java.awt.event.FocusEvent evt)
          {                                        
               // when the focus is going out of the text pane, update the query builder with new query text
               try
               {
                    queryBuilder1.setSQL(jTextPane1.getText());
               }
               catch (QueryBuilderException ex)
               {
                    Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(this, ex.getMessage());
               }
          }
     
     private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt)
     {
     
     System.out.println(" T2222222222222222222222");
     if (jTabbedPane1.getSelectedComponent() == dataPanel)
          {
               System.out.println(" T33333333333333333333333");
               // clear JTable
               jTable1.setModel(new DefaultTableModel(new Vector(), new Vector()));

               // Update the query text in the query builder.
               // this because the StateChanged event of the TabbedPane arrives before the JTextPane1 lost the focus
               // and updates the query text.
               try
               {
                    queryBuilder1.setSQL(jTextPane1.getText());
               }
               catch (QueryBuilderException ex)
               {
                    Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(this, ex.getMessage());
                    return;
               }

               // execute query:

               JdbcMetadataProvider metadataProvider = (JdbcMetadataProvider) queryBuilder1.getMetadataProvider();

               System.out.println("getmetadataprovider : >>>"+metadataProvider);
               if (queryBuilder1.getMetadataProvider() != null && queryBuilder1.getMetadataProvider().isConnected())
               {
               
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    try
                    {
                         ResultSet resultSet = null;
                         ParameterList parameters = queryBuilder1.getParameters();

                         // if query contains parameters...
                         if (parameters != null && parameters.getCount() > 0)
                         {
                              // prepare statement
                              PreparedStatement statement = metadataProvider.getConnection().prepareStatement(queryBuilder1.getSQL());

                              // ...ask user for parameter values:
                              for (int i = 0; i < parameters.getCount() ; i++)
                              {
                                   Parameter p = parameters.get(i);
                                   String message = "Please enter value for query parameter #" + String.valueOf(i + 1) + ":" +
                                             "\nname: " + p.getFullName() +
                                             "\ntype: " + typeToString(p.getDataType());

                                   // ask for parameter value
                                   String value = JOptionPane.showInputDialog(this, message, "Enter value for parameter",
                                             JOptionPane.QUESTION_MESSAGE);

                                   if (value != null)
                                   {
                                        //set entered parameter value to the prepared statement
                                        statement.setObject(i + 1, value, p.getDataType());
                                   }
                              }

                              statement.execute();
                              resultSet = statement.getResultSet();
                         }
                         else // just execute the query
                         {
                              resultSet = metadataProvider.getConnection().createStatement().executeQuery(queryBuilder1.getSQL());
                         }

                         // fill JTable
                         FillTableFromResultSet(resultSet);
                    }
                    catch (SQLException ex)
                    {
                         Logger.getLogger(QueryBuilderApplet.class.getName()).log(Level.SEVERE, null, ex);
                         JOptionPane.showMessageDialog(this, ex.getMessage());
                    }
                    finally
                    {
                         setCursor(Cursor.getDefaultCursor());
                    }

               }
          }
     }
     
     
          private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
     // TODO add your handling code here:
     try
               {
                    queryBuilder1.setSQL(jTextPane1.getText());
                    System.out.println("this>>>>>>>>>>>> 1111:"+this);
     System.out.println(" Save Print : >> " +queryBuilder1.getSQL());
     if(win != null){
     try{
          String command = evt.getActionCommand();
          System.out.println("Command>>>>>>>>>>>> :"+command);
          
               //System.out.println("this>>>>>>>>>>>>222 :"+this);
               //win.eval("window.close();");
               String query = queryBuilder1.getSQL();
               win.call("getSqlQuery", new String[]{query});
     
     }catch(JSException ex){
          ex.printStackTrace();
     }
     }
               }
               catch (QueryBuilderException ex)
               {
                    Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(this, ex.getMessage());
               }
     }//GEN-LAST:event_jButton1ActionPerformed

          
     private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
     // TODO add your handling code here:
     System.out.println(">>>>>> "+evt.getSource());
     queryBuilder1.setSQL(evt.getSource().toString());
     System.out.println(" Cancel Print : >> " +queryBuilder1.getSQL());
     if(win != null){
     try{
          //JSObject win = JSObject.getWindow(null);
               //win.eval("window.close();");
          String query = queryBuilder1.getSQL();
          win.call("getSqlQuery", new String[]{query});
     }catch(JSException ex){
          ex.printStackTrace();
     }
     }
     }//GEN-LAST:event_jButton3ActionPerformed

     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JPanel dataPanel;

     private javax.swing.JScrollPane jScrollPane1;
     private javax.swing.JScrollPane jScrollPane2;
     private javax.swing.JSplitPane jSplitPane1;
     private javax.swing.JTabbedPane jTabbedPane1;
     private javax.swing.JTable jTable1;
     private javax.swing.JTextPane jTextPane1;
     private javax.swing.JButton jButtonSave;
     private javax.swing.JButton jButtonCancel;
     private javax.swing.JPanel jPanel1;
     private javax.swing.JPanel jPanel2;
     
     // End of variables declaration

     public HashMap getConnParameters (String repoName, String legalEntityID,String connID)
{
System.out.println("--getConnParameters--");
          HashMap hsp = new HashMap();
try {
InputStream urlInput =null;
HttpURLConnection con =null;
URL uri=new URL(getCodeBase(),"QueryBuilderConninfoGrabber?CONN="+connID+"&RN="+URLEncoder.encode(repoName)+"&LE="+legalEntityID);
con =(HttpURLConnection)uri.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestMethod("POST");
con.setRequestProperty("Accept-Language", "en");
con.setRequestProperty("content-type", "text/html");
urlInput=con.getInputStream();
ObjectInputStream ois=new ObjectInputStream(urlInput);
Object obj= ois.readObject();
hsp=(HashMap) obj;
} catch (Exception e)
{
e.printStackTrace();
}
return hsp;
}
     
     public static String typeToString(int sqlType)
          {
               switch (sqlType)
               {
                    case Types.ARRAY: return "ARRAY";
                    case Types.BIGINT: return "BIGINT";
                    case Types.BINARY: return "BINARY";
                    case Types.BIT: return "BIT";
                    case Types.BLOB: return "BLOB";
                    case Types.BOOLEAN: return "BOOLEAN";
                    case Types.CHAR: return "CHAR";
                    case Types.CLOB: return "CLOB";
                    case Types.DATALINK: return "DATALINK";
                    case Types.DATE: return "DATE";
                    case Types.DECIMAL: return "DECIMAL";
                    case Types.DISTINCT: return "DISTINCT";
                    case Types.DOUBLE: return "DOUBLE";
                    case Types.FLOAT: return "FLOAT";
                    case Types.INTEGER: return "INTEGER";
                    case Types.JAVA_OBJECT: return "JAVA_OBJECT";
                    case Types.LONGNVARCHAR: return "LONGNVARCHAR";
                    case Types.LONGVARBINARY: return "LONGVARBINARY";
                    case Types.LONGVARCHAR: return "LONGVARCHAR";
                    case Types.NCHAR: return "NCHAR";
                    case Types.NCLOB: return "NCLOB";
                    case Types.NULL: return "NULL";
                    case Types.NUMERIC: return "NUMERIC";
                    case Types.NVARCHAR: return "NVARCHAR";
                    case Types.OTHER: return "OTHER";
                    case Types.REAL: return "REAL";
                    case Types.REF: return "REF";
                    case Types.ROWID: return "ROWID";
                    case Types.SMALLINT: return "SMALLINT";
                    case Types.SQLXML: return "SQLXML";
                    case Types.STRUCT: return "STRUCT";
                    case Types.TIME: return "TIME";
                    case Types.TIMESTAMP: return "TIMESTAMP";
                    case Types.TINYINT: return "TINYINT";
                    case Types.VARBINARY: return "VARBINARY";
                    case Types.VARCHAR: return "VARCHAR";
                    default: return "UNKNOWN";
               }
          }
}
  • 1. Re: How to connect to database from applet
    tschodt Pro
    Currently Being Moderated
    926622 wrote:
    HI ...
    plz hlep me....
    I'm having an applet where we should display the database values in the applet...
    It works fine in the local system(same network)...
    but when its in the server, we r getting null values in the local system..
    I created a policy file and also added that url in java.security but came error below(different network)...
    {code}
    java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:273)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:327)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:360)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:150)
         at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at QueryBuilderApplet$1.run(QueryBuilderApplet.java:132)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
         at java.awt.EventQueue.access$000(Unknown Source)
         at java.awt.EventQueue$3.run(Unknown Source)
         at java.awt.EventQueue$3.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    {code}
    my applet code is :
    {code}
    
    import java.awt.KeyboardFocusManager;
    import java.awt.event.KeyEvent;
    import java.awt.Cursor;
    import java.io.InputStream;
    import java.io.ObjectInputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLEncoder;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Vector;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    //Imports for getDataClass
    import java.sql.*;
    import sun.jdbc.odbc.JdbcOdbcDriver;
    
    import javax.swing.JApplet;
    import javax.swing.JOptionPane;
    import javax.swing.KeyStroke;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    
    import netscape.javascript.JSObject;
    import netscape.javascript.JSException;
    
    import com.adbs.metadata.JdbcMetadataProvider;
    import com.adbs.querybuilder.Parameter;
    import com.adbs.querybuilder.ParameterList;
    import com.adbs.querybuilder.PlainTextSQLBuilder;
    import com.adbs.querybuilder.QueryBuilderException;
    import com.adbs.querybuilder.SQLUpdatedEvent;
    import com.adbs.querybuilder.SQLUpdatedEventListener;
    import com.adbs.syntax.AutoSyntaxProvider;
    import com.adbs.syntax.DB2SyntaxProvider;
    import com.adbs.syntax.MSSQLSyntaxProvider;
    import com.adbs.syntax.MySQLSyntaxProvider;
    import com.adbs.syntax.OracleSyntaxProvider;
    import com.adbs.syntax.PostgreSQLSyntaxProvider;
    import com.adbs.syntax.SybaseSyntaxProvider;
    //import com.google.gwt.user.client.ui.MouseListener;
    import com.adbs.syntax.UniversalSyntaxProvider;
    
    public class QueryBuilderApplet extends JApplet {
         
         private JSObject win;
         private String connServer;
         private String connName;
         private String query;
         private String connId;
         private String le;
         private String repoName;
    
         private String connUrl;
         private String driver;
         private String userName;
         private String passWord;
         private com.adbs.querybuilder.QueryBuilder queryBuilder1;
         private JdbcMetadataProvider metadataProvider = new JdbcMetadataProvider();
    private static final long serialVersionUID = 1L;
    
    private PlainTextSQLBuilder plainTextSQLBuilder1 = new PlainTextSQLBuilder();
    
    private String list;
    
    
         public String getQuery(){
              list="No-List";
                        list = queryBuilder1.getSQL();
              return list;
         }
         
         @Override
         
         
         public void init() {
              System.out.println(">>>>>>>>>>>> init()  >>>>>>");
              connServer = getParameter("type");
              connName = getParameter("name");
              query = getParameter("qry");
              connId = getParameter("connId");
              le = getParameter("le");
              repoName =getParameter("repoName");
              win = JSObject.getWindow(this);
              final StringBuffer metaData = new StringBuffer();     
              metaData.append(getMetadataFileObject( connServer, connName));
              final HashMap hsp = getConnParameters (repoName, le, connId);
         connUrl = (String) hsp.get("setURL");
         driver = (String)hsp.get("setDriver");
         userName = (String)hsp.get("setUserName");
         passWord = (String)hsp.get("setPassword");
         
         try
                   {
                     java.awt.EventQueue.invokeAndWait(new Runnable()
                        {
                         public void run()
                             {
                                  // set native Look'n'Feel
                                  try
                                  {
                                       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                                  }
                                  catch (Exception ex)
                                  {
                                       System.out.println(ex.getMessage());
                                  }
                                  
                                  //init();
                                  initComponents();
                                  
                                  if ("oracle".equalsIgnoreCase(connServer))
                                 {
                                           
                                      try{
                                          Class.forName(driver).newInstance();
                                      }catch(Exception e){
                                      }try{     
                                          metadataProvider.setConnection(DriverManager.getConnection(connUrl, userName,passWord));
                                    } catch (SQLException e) {
                                          e.printStackTrace();
                                    }
                                    queryBuilder1.setMetadataProvider(metadataProvider);
                                      OracleSyntaxProvider syntaxProvider = new OracleSyntaxProvider();
                                    queryBuilder1.setSyntaxProvider(syntaxProvider);
                                    
                                      
                                 }
                                  //set up SQL builder:
                                  plainTextSQLBuilder1.setQueryBuilder(queryBuilder1);
                                  
                                  // handle the notification from plainTextSQLBuilder1 about the query text has been changed
                                  plainTextSQLBuilder1.addSQLUpdatedEventListener(new SQLUpdatedEventListener()
                                  {
                                       @Override
                                       public void sqlUpdatedEventOccurred(SQLUpdatedEvent event)
                                       {
                                            try
                                            {
                                                 jTextPane1.setText(plainTextSQLBuilder1.getSQL());
                                            }
                                            catch (QueryBuilderException ex)
                                            {
                                                 JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                                            }
                                       }
                                  });
    
                                  // Load metadata from XML file located in resources (for demonstration purposes)
                                  try
                                  {
                                       queryBuilder1.getMetadataContainer().loadFromXML(metaData.toString()); //sb.toString()
                                       
                                       System.out.println("applet @176  : Write successfully.......");
                                  
                                  }
                                  catch (Exception ex)
                                  {
                                       Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                                       JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                                  }
                          if (!("".equals(query))){
                                       try
                                       {
                                            queryBuilder1.setSQL(query);
                                       }
                                       catch (QueryBuilderException ex)
                                       {
                                            JOptionPane.showMessageDialog(QueryBuilderApplet.this, ex.getMessage());
                                       }
                             }
                                  // force the jTextPane1 to move the focus on the Tab key:
                               KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
                                  HashSet keystrokes = new HashSet();
                                  keystrokes.add(tab);
                                  jTextPane1.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keystrokes);
    
                                  KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK);
                                  keystrokes = new HashSet();
                                  keystrokes.add(shiftTab);
                                  jTextPane1.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keystrokes);
                         }
                     });
                 }
                   catch (Exception ex)
                   {
                     ex.printStackTrace();
                 }
                   
             }
    
          public String getMetadataFileObject (String connServer, String connName)
             {
                  System.out.println(">>>>>>>>>>>> getMetadataFileObject() >>>>>>");
                  System.out.println("connServer  "+connServer+" cccName  "+connName);
                 Vector classObj = new Vector();
                 String result="";
                 try {
                      
                     InputStream urlInput =null;
                        HttpURLConnection con =null;
                        
                        URL uri=new URL(getCodeBase(),"GetMetaDataFile?CONN_TYPE="+URLEncoder.encode(connServer)+"&CONN_NAME="+URLEncoder.encode(connName));
                        
                        con =(HttpURLConnection)uri.openConnection();
                        con.setDoInput(true);
                        con.setDoOutput(true);
                        con.setUseCaches(false);
                        con.setRequestMethod("POST");
                        con.setRequestProperty("Accept-Language", "en");
                        con.setRequestProperty("content-type", "text/html");
                        urlInput=con.getInputStream();
                        ObjectInputStream ois=new ObjectInputStream(urlInput);
                        Object obj= ois.readObject();
                        
                        String fileStr = (String)obj;
                        /*
                        File fname = new File("C:"+File.separator+"ice_store"+File.separator+"data"+File.separator+"metadata");
                        if (!fname.exists()){
                             //System.out.println("CREatingggggggggggggggggggggg:::::::::::::::::::::::::");
                             fname.mkdirs();
                        }     
                        String fileName = fname+File.separator+connName+".xml";
                        byte[] fileStream = fileStr.getBytes();
                        FileOutputStream fos = new FileOutputStream(fileName);

                        fos.write(fileStream);
                        fos.flush();
                        fos.close();
                        */
                        result = fileStr;
                        System.out.println("Received MetaData conetent displaying...");
                        urlInput.close();
         } catch (Exception e)
         {
         e.printStackTrace();
         }
         
         return result;
         }
         
              private void FillTableFromResultSet(final ResultSet resultSet)
              {
                   try
                   {
                        ResultSetMetaData metaData = resultSet.getMetaData();

                        int columnCount = metaData.getColumnCount();

                        Vector columns = new Vector(columnCount);

                        //store column names
                        for (int i = 1; i <= columnCount; i++)
                        {
                             columns.add(metaData.getColumnName(i));
                        }

                        Vector data = new Vector();
                        Vector row;

                        //store row data
                        while (resultSet.next())
                        {
                             row = new Vector(columnCount);

                             for (int i = 1; i <= columnCount; i++)
                             {
                                  row.add(resultSet.getString(i));
                             }

                             data.add(row);
                        }

                        jTable1.setModel(new DefaultTableModel(data, columns));
                   }
                   catch (SQLException ex)
                   {
                        Logger.getLogger(QueryBuilderApplet.class.getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(this, ex.getMessage());
                   }
              }
         
         @SuppressWarnings("unchecked")
         // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
         
         private void initComponents() {

    jTabbedPane1 = new javax.swing.JTabbedPane();
    jSplitPane1 = new javax.swing.JSplitPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextPane1 = new javax.swing.JTextPane();
    queryBuilder1 = new com.adbs.querybuilder.QueryBuilder();
    dataPanel = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jPanel1 = new javax.swing.JPanel();
    jButtonSave = new javax.swing.JButton();
    jButtonCancel = new javax.swing.JButton();

    setStub(null);

    jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
    public void stateChanged(javax.swing.event.ChangeEvent evt) {
         
    jTabbedPane1StateChanged(evt);
    }
    });

    jSplitPane1.setDividerLocation(450);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setResizeWeight(1.0);
    jSplitPane1.setRightComponent(jScrollPane1);
    jSplitPane1.setLeftComponent(queryBuilder1);
    jSplitPane1.setRightComponent(jScrollPane1);

    jTextPane1.setFont(new java.awt.Font("Monospaced", 0, 12));
    jTextPane1.setDropTarget(null);
    jTextPane1.addFocusListener(new java.awt.event.FocusAdapter() {
    public void focusLost(java.awt.event.FocusEvent evt) {

         jTextPane1FocusLost(evt);
    }
    });
    jScrollPane1.setViewportView(jTextPane1);

    getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);

    jTabbedPane1.addTab("SQL", jSplitPane1);

    dataPanel.setLayout(new javax.swing.BoxLayout(dataPanel, javax.swing.BoxLayout.LINE_AXIS));

    jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
    {null, null, null, null},
    {null, null, null, null},
    {null, null, null, null},
    {null, null, null, null}
    },
    new String [] {
    "Title 1", "Title 2", "Title 3", "Title 4"
    }
    ));
    jScrollPane2.setViewportView(jTable1);

    dataPanel.add(jScrollPane2);

    jTabbedPane1.addTab("Data", dataPanel);
    getContentPane().add(jTabbedPane1);

    jButtonSave.setText("SAVE");
    jButtonSave.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButtonSaveActionPerformed(evt);
    }
    });


    jButtonCancel.setText("CANCEL");
    jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    evt.setSource(query);
    jButtonCancelActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(panel1Layout);
    panel1Layout.setHorizontalGroup(
    panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
    .addContainerGap(1025, Short.MAX_VALUE)
    .addComponent(jButtonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jButtonCancel)
    .addGap(18, 18, 18))
    );
    panel1Layout.setVerticalGroup(
    panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jButtonSave)
    .addComponent(jButtonCancel))
    );
    getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

    }
         


         private void jTextPane1FocusLost(java.awt.event.FocusEvent evt)
              {                                        
                   // when the focus is going out of the text pane, update the query builder with new query text
                   try
                   {
                        queryBuilder1.setSQL(jTextPane1.getText());
                   }
                   catch (QueryBuilderException ex)
                   {
                        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(this, ex.getMessage());
                   }
              }
         
         private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt)
         {
         
         System.out.println(" T2222222222222222222222");
         if (jTabbedPane1.getSelectedComponent() == dataPanel)
              {
                   System.out.println(" T33333333333333333333333");
                   // clear JTable
                   jTable1.setModel(new DefaultTableModel(new Vector(), new Vector()));

                   // Update the query text in the query builder.
                   // this because the StateChanged event of the TabbedPane arrives before the JTextPane1 lost the focus
                   // and updates the query text.
                   try
                   {
                        queryBuilder1.setSQL(jTextPane1.getText());
                   }
                   catch (QueryBuilderException ex)
                   {
                        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(this, ex.getMessage());
                        return;
                   }

                   // execute query:

                   JdbcMetadataProvider metadataProvider = (JdbcMetadataProvider) queryBuilder1.getMetadataProvider();

                   System.out.println("getmetadataprovider : >>>"+metadataProvider);
                   if (queryBuilder1.getMetadataProvider() != null && queryBuilder1.getMetadataProvider().isConnected())
                   {
                   
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                        try
                        {
                             ResultSet resultSet = null;
                             ParameterList parameters = queryBuilder1.getParameters();

                             // if query contains parameters...
                             if (parameters != null && parameters.getCount() > 0)
                             {
                                  // prepare statement
                                  PreparedStatement statement = metadataProvider.getConnection().prepareStatement(queryBuilder1.getSQL());

                                  // ...ask user for parameter values:
                                  for (int i = 0; i < parameters.getCount() ; i++)
                                  {
                                       Parameter p = parameters.get(i);
                                       String message = "Please enter value for query parameter #" + String.valueOf(i + 1) + ":" +
                                                 "\nname: " + p.getFullName() +
                                                 "\ntype: " + typeToString(p.getDataType());

                                       // ask for parameter value
                                       String value = JOptionPane.showInputDialog(this, message, "Enter value for parameter",
                                                 JOptionPane.QUESTION_MESSAGE);

                                       if (value != null)
                                       {
                                            //set entered parameter value to the prepared statement
                                            statement.setObject(i + 1, value, p.getDataType());
                                       }
                                  }

                                  statement.execute();
                                  resultSet = statement.getResultSet();
                             }
                             else // just execute the query
                             {
                                  resultSet = metadataProvider.getConnection().createStatement().executeQuery(queryBuilder1.getSQL());
                             }

                             // fill JTable
                             FillTableFromResultSet(resultSet);
                        }
                        catch (SQLException ex)
                        {
                             Logger.getLogger(QueryBuilderApplet.class.getName()).log(Level.SEVERE, null, ex);
                             JOptionPane.showMessageDialog(this, ex.getMessage());
                        }
                        finally
                        {
                             setCursor(Cursor.getDefaultCursor());
                        }

                   }
              }
         }
         
         
              private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
         // TODO add your handling code here:
         try
                   {
                        queryBuilder1.setSQL(jTextPane1.getText());
                        System.out.println("this>>>>>>>>>>>> 1111:"+this);
         System.out.println(" Save Print : >> " +queryBuilder1.getSQL());
         if(win != null){
         try{
              String command = evt.getActionCommand();
              System.out.println("Command>>>>>>>>>>>> :"+command);
              
                   //System.out.println("this>>>>>>>>>>>>222 :"+this);
                   //win.eval("window.close();");
                   String query = queryBuilder1.getSQL();
                   win.call("getSqlQuery", new String[]{query});
         
         }catch(JSException ex){
              ex.printStackTrace();
         }
         }
                   }
                   catch (QueryBuilderException ex)
                   {
                        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(this, ex.getMessage());
                   }
         }//GEN-LAST:event_jButton1ActionPerformed

              
         private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
         // TODO add your handling code here:
         System.out.println(">>>>>> "+evt.getSource());
         queryBuilder1.setSQL(evt.getSource().toString());
         System.out.println(" Cancel Print : >> " +queryBuilder1.getSQL());
         if(win != null){
         try{
              //JSObject win = JSObject.getWindow(null);
                   //win.eval("window.close();");
              String query = queryBuilder1.getSQL();
              win.call("getSqlQuery", new String[]{query});
         }catch(JSException ex){
              ex.printStackTrace();
         }
         }
         }//GEN-LAST:event_jButton3ActionPerformed

         // Variables declaration - do not modify//GEN-BEGIN:variables
         private javax.swing.JPanel dataPanel;

         private javax.swing.JScrollPane jScrollPane1;
         private javax.swing.JScrollPane jScrollPane2;
         private javax.swing.JSplitPane jSplitPane1;
         private javax.swing.JTabbedPane jTabbedPane1;
         private javax.swing.JTable jTable1;
         private javax.swing.JTextPane jTextPane1;
         private javax.swing.JButton jButtonSave;
         private javax.swing.JButton jButtonCancel;
         private javax.swing.JPanel jPanel1;
         private javax.swing.JPanel jPanel2;
         
         // End of variables declaration

         public HashMap getConnParameters (String repoName, String legalEntityID,String connID)
    {
    System.out.println("--getConnParameters--");
              HashMap hsp = new HashMap();
    try {
    InputStream urlInput =null;
    HttpURLConnection con =null;
    URL uri=new URL(getCodeBase(),"QueryBuilderConninfoGrabber?CONN="+connID+"&RN="+URLEncoder.encode(repoName)+"&LE="+legalEntityID);
    con =(HttpURLConnection)uri.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setRequestMethod("POST");
    con.setRequestProperty("Accept-Language", "en");
    con.setRequestProperty("content-type", "text/html");
    urlInput=con.getInputStream();
    ObjectInputStream ois=new ObjectInputStream(urlInput);
    Object obj= ois.readObject();
    hsp=(HashMap) obj;
    } catch (Exception e)
    {
    e.printStackTrace();
    }
    return hsp;
    }
         
         public static String typeToString(int sqlType)
              {
                   switch (sqlType)
                   {
                        case Types.ARRAY: return "ARRAY";
                        case Types.BIGINT: return "BIGINT";
                        case Types.BINARY: return "BINARY";
                        case Types.BIT: return "BIT";
                        case Types.BLOB: return "BLOB";
                        case Types.BOOLEAN: return "BOOLEAN";
                        case Types.CHAR: return "CHAR";
                        case Types.CLOB: return "CLOB";
                        case Types.DATALINK: return "DATALINK";
                        case Types.DATE: return "DATE";
                        case Types.DECIMAL: return "DECIMAL";
                        case Types.DISTINCT: return "DISTINCT";
                        case Types.DOUBLE: return "DOUBLE";
                        case Types.FLOAT: return "FLOAT";
                        case Types.INTEGER: return "INTEGER";
                        case Types.JAVA_OBJECT: return "JAVA_OBJECT";
                        case Types.LONGNVARCHAR: return "LONGNVARCHAR";
                        case Types.LONGVARBINARY: return "LONGVARBINARY";
                        case Types.LONGVARCHAR: return "LONGVARCHAR";
                        case Types.NCHAR: return "NCHAR";
                        case Types.NCLOB: return "NCLOB";
                        case Types.NULL: return "NULL";
                        case Types.NUMERIC: return "NUMERIC";
                        case Types.NVARCHAR: return "NVARCHAR";
                        case Types.OTHER: return "OTHER";
                        case Types.REAL: return "REAL";
                        case Types.REF: return "REF";
                        case Types.ROWID: return "ROWID";
                        case Types.SMALLINT: return "SMALLINT";
                        case Types.SQLXML: return "SQLXML";
                        case Types.STRUCT: return "STRUCT";
                        case Types.TIME: return "TIME";
                        case Types.TIMESTAMP: return "TIMESTAMP";
                        case Types.TINYINT: return "TINYINT";
                        case Types.VARBINARY: return "VARBINARY";
                        case Types.VARCHAR: return "VARCHAR";
                        default: return "UNKNOWN";
                   }
              }
    }
    {code}

    Firewall issue?

    Can the machine the client is running on connect to port 1521 on the Oracle Database Server?
    (you can try this with telnet).

    Does the Oracle Database Server have USE_SHARED_SOCKET configured
    so port 1521 is the only port that needs to be allowed in the firewall config
    to allow client access to the Oracle Database Server?
  • 2. Re: How to connect to database from applet
    929625 Newbie
    Currently Being Moderated
    Thanks for ur reply..................
    I have to add this registry key HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_XE\USE_SHARED_SOCKET with value true.
    It works fine in the same network(database server- 192.168.1.103 and application- 192.168.1.109).
    But when its in the server, we r getting connection null in applet(database server- 192.168.1.103, application- 192.168.1.109 and application access from different network 99.44.103.148). In this situation we r getting error "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection". Plz help me.................
  • 3. Re: How to connect to database from applet
    tschodt Pro
    Currently Being Moderated
    926622 wrote:
    I have to add this registry key HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_XE\USE_SHARED_SOCKET with value true.
    It works fine in the same network(database server- 192.168.1.103 and application- 192.168.1.109).
    So it works on a IANA private network segment.
    But when its in the server, we r getting connection null in applet (database server- 192.168.1.103, application- 192.168.1.109 and application access from different network 99.44.103.148).
    The client will not be able to connect to a 192.168.x.x IP address over the internet.
    Is the server behind NAT?
    From a workstation on the same network segment as the server
    open a web browser and browse to one of the "what is my IP address" sites,
    do all workstation on this network segment show the same IP address when you do this?
    If you can run a web browser on the server you can do this from the server as well
    or if you don't have a GUI on the server you can use wget.

    tschodt wrote:

    Firewall issue?

    Can the machine the client is running on (99.44.103.148) connect to port 1521 on the Oracle Database Server?
    *(you can try this with telnet).*
    The client will not be able to connect to a 192.168.x.x IP address over the internet.
  • 4. Re: How to connect to database from applet
    929625 Newbie
    Currently Being Moderated
    Hi,
    Actually this is not a server machine from where i have to connect. It is just a local machine (in the network). Please let me know the exact step by step solution for this.
  • 5. Re: How to connect to database from applet
    tschodt Pro
    Currently Being Moderated
    926622 wrote:

    &#8302; &#8302; &#8302; Actually this is not a server machine from where i have to connect.
    It is just a local machine (in the network).
    If it hosts an Oracle Database that clients connect to, it is by definition a server.

    Please let me know the exact step by step solution for this.
    Please answer the question.
    tschodt wrote:

    Can the machine the client is running on connect to port 1521 on the Oracle Database Server?
    (you can try this with telnet).
  • 6. Re: How to connect to database from applet
    935143 Newbie
    Currently Being Moderated
    I believe you cannot access the database server from the applet served up by the app server... The applet spec specified you can only connect to the database server hosting the applet... Its a security design...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points