HI...
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...
java.sql.SQLException: JZ006: Caught IOException: java.net.UnknownHostException: ICEBOX55
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseErrorCheckDead(Unknown Source)
at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.login(Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.a(Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.handleHAFailover(Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.
my 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 String modifiedQuery; System.out.println(">>>>>>>>>>>> type >>>>>> "+connServer); //System.out.println(">>>>>>>>>>>> name >>>>>> "+connName); System.out.println(">>>>>>>>>>>> Query >>>>>> "+query);
// modifiedQuery = getModifiedQuery(query); // System.out.println(">>>>>>>>>>>> NewQry >>>>>> "+modifiedQuery);
final StringBuffer metaData = new StringBuffer(); metaData.append(getMetadataFileObject( connServer, connName)); final HashMap hsp = getConnParameters (repoName, le, connId); //final String connString = (String) hsp.get("setURL"); connUrl = (String) hsp.get("setURL"); driver = (String)hsp.get("setDriver"); userName = (String)hsp.get("setUserName"); passWord = (String)hsp.get("setPassword"); //System.out.println("URLLLLLLLLLLLLL ::::::: "+connString); System.out.println("setDriverrrrrrrr ::::::: "+(String)hsp.get("setDriver")); //System.out.println("passwoooordddddd ::::::: "+(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); } else if ("ODBC".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); AutoSyntaxProvider syntaxProvider = new AutoSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); } else if ("mssql".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); MSSQLSyntaxProvider syntaxProvider = new MSSQLSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); } else if ("mysql".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); MySQLSyntaxProvider syntaxProvider = new MySQLSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); } else if ("db2".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); DB2SyntaxProvider syntaxProvider = new DB2SyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); } else if ("postgres".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); PostgreSQLSyntaxProvider syntaxProvider = new PostgreSQLSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); } else if("sybase".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); SybaseSyntaxProvider syntaxProvider = new SybaseSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); }else if ("Hsql".equalsIgnoreCase(connServer)) { //String url= connString.replace(";","/"); try{ Class.forName(driver).newInstance(); }catch(Exception e){ }try{ metadataProvider.setConnection(DriverManager.getConnection(connUrl, userName,passWord)); } catch (SQLException e) { e.printStackTrace(); } queryBuilder1.setMetadataProvider(metadataProvider); AutoSyntaxProvider syntaxProvider = new AutoSyntaxProvider(); queryBuilder1.setSyntaxProvider(syntaxProvider); }else if ("TERADATA".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); AutoSyntaxProvider syntaxProvider = new AutoSyntaxProvider(); 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 initComponents() {
jSplitPane1 = new javax.swing.JSplitPane(); queryBuilder1 = new com.adbs.querybuilder.QueryBuilder(); jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jButtonSave = new javax.swing.JButton(); jButtonCancel = new javax.swing.JButton(); setStub(null); jSplitPane1.setDividerLocation(450); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setResizeWeight(1.0); jSplitPane1.setLeftComponent(queryBuilder1); jTextPane1.setFont(new java.awt.Font("Monospaced", 0, 12)); jTextPane1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jTextPane1FocusLost(evt); } }); jScrollPane1.setViewportView(jTextPane1); jSplitPane1.setRightComponent(jScrollPane1); getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER); jPanel1.setPreferredSize(new java.awt.Dimension(821, 30)); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel2.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647)); jPanel2.setPreferredSize(new java.awt.Dimension(821, 30)); jButtonSave.setText("SAVE"); jButtonSave.setActionCommand("SAVE"); jButtonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSaveActionPerformed(evt); } }); jButtonCancel.setText("CANCEL"); jButtonCancel.setActionCommand("CANCEL"); jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { evt.setSource(query); jButtonCancelActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(603, Short.MAX_VALUE) .addComponent(jButtonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) ); jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER); getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);
}// //GEN-END:initComponents//
*/ 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"; } }
}
Ads