sakthivel shan

Greenhorn
+ Follow
since Nov 11, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sakthivel shan

Dear All,
I want to refresh my JTable...So each and every time of refresh, it should show the updated data in the backend....i am using the below method to do that....i am trying to update my vectordata "Vector"...each time....but, stil it is not getting refreshed....how to do this....

public void refreshTable()
{
vectordata=getData_polleddetailspanel();
jscrollpane.invalidate();
jscrollpane.validate();
jscrollpane.repaint();
jtable.invalidate();
jtable.validate();
jtable.repaint();
}
waiting for ur reply,
Sakthivel S.

COMPLETE CODE:
****************
class PolledDetailsPanel extends JPanel
{
Vector vectorcolnames;
JTable jtable;
JScrollPane jscrollpane;
public PolledDetailsPanel()
{
vectorcolnames = new Vector(7);
vectorcolnames.addElement("File Type");
vectorcolnames.addElement("File Name");
vectorcolnames.addElement("Description");
vectorcolnames.addElement("Status");
vectorcolnames.addElement("Reason");
vectorcolnames.addElement("Created Date");
vectorcolnames.addElement("Modified Date");
mytablemodel2 = new MyTableModel(vectordata,vectorcolnames);
jtable = new JTable(mytablemodel2);
jtable.getTableHeader().setReorderingAllowed(false);
jtable.setRowSelectionAllowed(true);
jtable.setGridColor(Color.green);
jtable.setSelectionMode(0);
jtable.setShowHorizontalLines(true);
jtable.setPreferredScrollableViewportSize(new Dimension(520,150));
JPanel basepanel = new JPanel();
JPanel tablepanel = new JPanel();
JPanel buttonpanel = new JPanel();
basepanel.setLayout(new BoxLayout(basepanel, BoxLayout.Y_AXIS));
JButton delete = new JButton("Delete Data");
JButton save = new JButton("Save Data");
JButton close = new JButton("Refresh");
delete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
save.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
close.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
jscrollpane = new JScrollPane(jtable);
tablepanel.add(jscrollpane,"Center");
buttonpanel.add(delete);
buttonpanel.add(save);
buttonpanel.add(refresh);
basepanel.add(tablepanel);
basepanel.add(buttonpanel);
add(basepanel);
delete.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent)
{
String command=aevent.getActionCommand();
if(command.equals("Delete Data"))
{
int selected = jtable.getSelectedRow();
if (selected >=0)
{
javax.swing.table.DefaultTableModel model1=(javax.swing.table.DefaultTableModel) jtable.getModel();
model1.removeRow(selected);
}
}
}
});
save.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent)
{
String command=aevent.getActionCommand();
if(command.equals("Save Data"))
{
if(jtable.isEditing())
{
int row = jtable.getEditingRow();
int col = jtable.getEditingColumn();
jtable.getCellEditor(row,col).stopCellEditing();
}
int entry=0;
Vector basevector = mytablemodel2.getDataVector();
int cap_outer = basevector.size();
for(int index_outer=0;index_outer<cap_outer;index_outer++)
{
Vector innervector = (Vector)basevector.elementAt(index_outer);
int cap_inner = innervector.size();
for(int index_inner=0;index_inner<cap_inner;index_inner++)
{
if((innervector.elementAt(index_inner)==null) || (innervector.elementAt(index_inner).equals("")))
{
entry=1;
JOptionPane.showMessageDialog(jframe,"Please fill all the values","Error Message",JOptionPane.INFORMATION_MESSAGE);
break;
}
}
innervector=null;
if(entry==1)
break;
}
basevector=null;
if(entry==0)
{
saveData_polleddetailspanel();
JOptionPane.showMessageDialog(jframe,"Data Saved Successfully");
}
entry=0;
}
}
});
refresh.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){
refreshTable();
}});
}
*************************
public Vector getData_polleddetailspanel()
{
Vector vectordata=new Vector();
try
{
ResultSet resultset=stmt.executeQuery("Select * from pollingstatus");
Vector vector;
while(resultset.next())
{
vector = new Vector(7);
vector.addElement(resultset.getString(1));
vector.addElement(resultset.getString(2));
vector.addElement(resultset.getString(3));
vector.addElement(resultset.getString(4));
vector.addElement(resultset.getString(5));
vector.addElement(resultset.getString(6));
vector.addElement(resultset.getString(7));
vectordata.addElement(vector);
}
}
catch(Exception exp)
{exp.printStackTrace();}
System.out.println(vectordata.size());
return(vectordata);
}
21 years ago
Dear All,
while loading this frame i am gettting the following error...
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Function sequence error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:4089)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:1902)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:1810)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java, Compiled C
ode)
at UserInterface.getData_polleddetailspanel(UserInterface.java, Compiled Code)
at UserInterface$PolledDetailsPanel.<init>(UserInterface.java:374)
at UserInterface.<init>(UserInterface.java:35)
at UserEntry$1.actionPerformed(UserEntry.java:107)
at java.awt.Button.processActionEvent(Button.java:308)
at java.awt.Button.processEvent(Button.java:281)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.ja
va, Compiled Code)
at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java
:95)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:90)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
i tried out all the combinations of function calling sequences...but still it is throwing the error....could any one pl. sort out the problem....
bye & waiting for ur reply,
Sakthivel S.

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import java.sql.*;

/* class "UserInterface" - begin */
public class UserInterface extends JFrame
{
JFrame jframe;
JTabbedPane jtp;
MyTableModel mytablemodel;
Connection con;
Statement stmt;
JTextField basedir,inputbasedir,ccode;
public UserInterface (String cookie)
{
connectToBackend();
jtp = new JTabbedPane();
jtp.addChangeListener(new ChangeListener(){public void stateChanged(ChangeEvent e){if(jtp.getSelectedIndex()== 1)getData_pathpanel();}});
PollPanel pollpanel=new PollPanel(cookie);
PathPanel pathpanel=new PathPanel();
DetailsPanel detailspanel=new DetailsPanel();
PolledDetailsPanel polleddetailspanel=new PolledDetailsPanel();
jtp.addTab("Polling",pollpanel);
jtp.addTab("File Path",pathpanel);
jtp.addTab("Dir Details",detailspanel);
jtp.addTab("Polled Details",polleddetailspanel);
pollpanel.setBorder(BorderFactory.createLineBorder(Color.blue,2));
pathpanel.setBorder(BorderFactory.createLineBorder(Color.black,2));
detailspanel.setBorder(BorderFactory.createLineBorder(Color.white,2));
polleddetailspanel.setBorder(BorderFactory.createLineBorder(Color.white,2));
jframe = new JFrame("ASP - Welcome to the File Poller System");
jframe.setBackground(Color.lightGray);
jframe.setSize(580, 290);
center(jframe);
jframe.setVisible(true);
jframe.setResizable(false);
jframe.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){dispose();System.exit(0);}});
jframe.getContentPane().add(jtp);
}
/* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& POLL PANEL &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
class PollPanel extends JPanel
{
FilePoller filepoller;
String cookievalue="";
JButton startpolling;
JButton stoppolling;
public PollPanel(String cookie)
{
cookievalue=cookie;
JPanel bottompanel = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
bottompanel.setLayout(new BoxLayout(bottompanel, BoxLayout.Y_AXIS));
panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));
JLabel title = new JLabel("Welcome to File Poller System");
title.setHorizontalTextPosition(JLabel.CENTER);
title.setForeground(Color.blue);
title.setFont(new java.awt.Font("Serif",1,20));
startpolling = new JButton("Start Polling");
stoppolling = new JButton("Stop Polling");
JButton close = new JButton("Close");
startpolling.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
stoppolling.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
close.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
panel1.add(title);
panel2.add(startpolling);
panel2.add(Box.createHorizontalStrut(8));
panel2.add(stoppolling);
panel2.add(Box.createHorizontalStrut(8));
panel2.add(close);
bottompanel.add(panel1);
bottompanel.add(Box.createVerticalStrut(80));
bottompanel.add(panel2);
bottompanel.add(Box.createVerticalStrut(16));
add(bottompanel);

filepoller = new FilePoller();
startpolling.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent aevent)
{
startpolling.setEnabled(false);
(new Thread() {
public void run() {
filepoller.decider="1";
filepoller.fpoller(cookievalue);
startpolling.setEnabled(true);}}
).start();
}
});

stoppolling.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent aevent){filepoller.stopPolling();}
});
close.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){System.exit(0);dispose();}});
}
}
/* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& POLL PANEL &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
/* ################################################# PATH PANEL ########################################## */
class PathPanel extends JPanel
{
JPanel basepanel,panel1,panel2,panel1_1,panel1_2,panel1_3;
JLabel jlabel1,jlabel2,jlabel3;
JButton save,getdata,clear,close;
public PathPanel()
{
basepanel = new JPanel();
panel1 = new JPanel();
panel2 = new JPanel();
panel1_1 = new JPanel();
panel1_2 = new JPanel();
panel1_3 = new JPanel();
basepanel.setLayout(new BoxLayout(basepanel, BoxLayout.Y_AXIS));
panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
panel1_1.setLayout(new BoxLayout(panel1_1, BoxLayout.X_AXIS));
panel1_2.setLayout(new BoxLayout(panel1_2, BoxLayout.X_AXIS));
panel1_3.setLayout(new BoxLayout(panel1_3, BoxLayout.X_AXIS));
panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));
panel1.add(panel1_1);
panel1.add(Box.createVerticalStrut(2));
panel1.add(panel1_2);
panel1.add(Box.createVerticalStrut(2));
panel1.add(panel1_3);
basepanel.add(Box.createVerticalStrut(16));
basepanel.add(panel1);
basepanel.add(Box.createVerticalStrut(22));
basepanel.add(panel2);
add(basepanel);
jlabel1=new JLabel("Base Directory :");
jlabel2=new JLabel("Input Base Dir :");
jlabel3=new JLabel("Company Code :");
jlabel1.setForeground(Color.black);
jlabel2.setForeground(Color.black);
jlabel3.setForeground(Color.black);
basedir = new JTextField(16);
inputbasedir = new JTextField(16);
ccode = new JTextField(16);
save = new JButton("SAVE");
getdata = new JButton("GET DATA");
clear = new JButton("Clear");
close = new JButton("Close");
save.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
getdata.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
clear.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
close.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
panel1_1.add(jlabel1);
panel1_1.add(Box.createHorizontalStrut(6));
panel1_1.add(basedir);
panel1_2.add(jlabel2);
panel1_2.add(Box.createHorizontalStrut(10));
panel1_2.add(inputbasedir);
panel1_3.add(jlabel3);
panel1_3.add(Box.createHorizontalStrut(5));
panel1_3.add(ccode);
panel2.add(save);
panel2.add(getdata);
panel2.add(clear);
panel2.add(close);
save.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent aevent)
{
if( (basedir.getText()).equals("") || (inputbasedir.getText()).equals("") || (ccode.getText()).equals(""))
{JOptionPane.showMessageDialog(jframe,"Please fill all the fields","Error Message",JOptionPane.INFORMATION_MESSAGE);}
else
{
recordCreation(basedir.getText(),inputbasedir.getText(),ccode.getText());
JOptionPane.showMessageDialog(jframe,"Data Saved Successfully");
basedir.setText(null);
inputbasedir.setText(null);
ccode.setText(null);
}
}
}
);
getdata.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){getData_pathpanel();}});
clear.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent aevent)
{
basedir.setText(null);
inputbasedir.setText(null);
ccode.setText(null);
}
});
close.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){System.exit(0);dispose();}});
}
}
/* ################################################# PATH PANEL ########################################## */
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DETAILS PANEL >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
class DetailsPanel extends JPanel
{
Vector vectorcolnames;
JTable jtable;
public DetailsPanel()
{
vectorcolnames = new Vector(6);
vectorcolnames.addElement("Dir Name");
vectorcolnames.addElement("File Type");
vectorcolnames.addElement("Description");
vectorcolnames.addElement("Solution Type");
vectorcolnames.addElement("Solution Code");
vectorcolnames.addElement("DB Name");
Vector vectordata=new Vector();
vectordata=getData_detailspanel();
mytablemodel = new MyTableModel(vectordata,vectorcolnames);
jtable = new JTable(mytablemodel);
jtable.getTableHeader().setReorderingAllowed(false);
jtable.setRowSelectionAllowed(true);
jtable.setGridColor(Color.green);
jtable.setSelectionMode(0);
jtable.setShowHorizontalLines(true);
jtable.setPreferredScrollableViewportSize(new Dimension(520,150));
JPanel basepanel = new JPanel();
JPanel tablepanel = new JPanel();
JPanel buttonpanel = new JPanel();
basepanel.setLayout(new BoxLayout(basepanel, BoxLayout.Y_AXIS));
JButton add = new JButton("Add Data");
JButton delete = new JButton("Delete Data");
JButton save = new JButton("Save Data");
JButton close = new JButton("Close");
add.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
delete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
save.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
close.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
tablepanel.add(new JScrollPane(jtable),"Center");
buttonpanel.add(add);
buttonpanel.add(delete);
buttonpanel.add(save);
buttonpanel.add(close);
basepanel.add(tablepanel);
basepanel.add(buttonpanel);
add(basepanel);
add.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){
String command=aevent.getActionCommand();
if(command.equals("Add Data"))
{
Integer[] newCells = new Integer[mytablemodel.getColumnCount()];
javax.swing.table.DefaultTableModel model1=(javax.swing.table.DefaultTableModel) jtable.getModel();
model1.addRow(newCells);
}
}});
save.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent)
{
String command=aevent.getActionCommand();
if(command.equals("Save Data"))
{
if(jtable.isEditing())
{
int row = jtable.getEditingRow();
int col = jtable.getEditingColumn();
jtable.getCellEditor(row,col).stopCellEditing();
}
int entry=0;
Vector basevector = mytablemodel.getDataVector();
int cap_outer = basevector.size();
for(int index_outer=0;index_outer<cap_outer;index_outer++)
{
Vector innervector = (Vector)basevector.elementAt(index_outer);
int cap_inner = innervector.size();
for(int index_inner=0;index_inner<cap_inner;index_inner++)
{
if((innervector.elementAt(index_inner)==null) || (innervector.elementAt(index_inner).equals("")))
{
entry=1;
JOptionPane.showMessageDialog(jframe,"Please fill all the values","Error Message",JOptionPane.INFORMATION_MESSAGE);
break;
}
}
innervector=null;
if(entry==1)
break;
}
basevector=null;
if(entry==0)
{
saveData_detailspanel();
JOptionPane.showMessageDialog(jframe,"Data Saved Successfully");
}
entry=0;
}
}
});
delete.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent)
{
String command=aevent.getActionCommand();
if(command.equals("Delete Data"))
{
int selected = jtable.getSelectedRow();
if (selected >=0)
{
javax.swing.table.DefaultTableModel model1=(javax.swing.table.DefaultTableModel) jtable.getModel();
model1.removeRow(selected);
}
}
}
});
close.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){System.exit(0);dispose();}});
}
}

class MyTableModel extends DefaultTableModel
{
public MyTableModel( Vector data,Vector columnnames ){super(data,columnnames);}
public void moveRow( int startIndex,int endIndex,int toIndex ) {}
public boolean isCellEditable(int row, int col) {return true;}
}
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DETAILS PANEL >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */

/* ################################################# POLLED DETAILS PANEL ################################ */
class PolledDetailsPanel extends JPanel
{
Vector vectorcolnames;
JTable jtable;
public PolledDetailsPanel()
{
vectorcolnames = new Vector(7);
vectorcolnames.addElement("File Type");
vectorcolnames.addElement("File Name");
vectorcolnames.addElement("Description");
vectorcolnames.addElement("Status");
vectorcolnames.addElement("Reason");
vectorcolnames.addElement("Created Date");
vectorcolnames.addElement("Modified Date");
Vector vectordata=new Vector();
vectordata=getData_polleddetailspanel();
mytablemodel = new MyTableModel(vectordata,vectorcolnames);
jtable = new JTable(mytablemodel);
jtable.getTableHeader().setReorderingAllowed(false);
jtable.setRowSelectionAllowed(true);
jtable.setGridColor(Color.green);
jtable.setSelectionMode(0);
jtable.setShowHorizontalLines(true);
jtable.setPreferredScrollableViewportSize(new Dimension(520,150));
JPanel basepanel = new JPanel();
JPanel tablepanel = new JPanel();
JPanel buttonpanel = new JPanel();
basepanel.setLayout(new BoxLayout(basepanel, BoxLayout.Y_AXIS));
JButton delete = new JButton("Delete Data");
JButton close = new JButton("Close");
delete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
close.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
tablepanel.add(new JScrollPane(jtable),"Center");
buttonpanel.add(delete);
buttonpanel.add(close);
basepanel.add(tablepanel);
basepanel.add(buttonpanel);
add(basepanel);
delete.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent)
{
String command=aevent.getActionCommand();
if(command.equals("Delete Data"))
{
int selected = jtable.getSelectedRow();
if (selected >=0)
{
javax.swing.table.DefaultTableModel model1=(javax.swing.table.DefaultTableModel) jtable.getModel();
model1.removeRow(selected);
}
}
}
});
close.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent aevent){System.exit(0);dispose();}});
}
}
/* ################################################# POLLED DETAILS PANEL ################################ */

/* ************************************************* COMMON FUNCTIONS ************************************ */
public void connectToBackend()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc atafetcher","","");
stmt=con.createStatement();
}
catch(Exception exp)
{
System.out.println(exp);
}
}
public void closeConnections()
{
try
{
con.close();
con = null;
}
catch(Exception exp)
{exp.printStackTrace();}
}
public void center(JFrame jframe)
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = jframe.getSize();
if (frameSize.height > screenSize.height)
frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width)
frameSize.width = screenSize.width;
jframe.setLocation((screenSize.width - frameSize.width)/2,(screenSize.height - frameSize.height)/2);
}
public static void main (String args[])
{
UserInterface userinterface = new UserInterface("hai");
}
/* ************************************************* COMMON FUNCTIONS ************************************ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Record Operations for Tab2, Tab3 & Tab4 @@@@@@@@@@@@@@@@@@@@@@@@@@ */
public void getData_pathpanel()
{
String val1="";
String val2="";
String val3="";
try
{
ResultSet resultset = stmt.executeQuery("select * from profile");
while(resultset.next())
{
val1 = resultset.getString(1);
val2 = resultset.getString(2);
val3 = resultset.getString(3);
}
basedir.setText(val1);
inputbasedir.setText(val2);
ccode.setText(val3);
}
catch(Exception exp)
{System.out.println(exp);}
}
public void recordCreation(String basedir, String inputbasedir, String ccode)
{
try
{
stmt.executeUpdate("Delete * from profile");
stmt.executeUpdate("Insert into profile values(" + "'"+ basedir +"'" + "," + "'"+ inputbasedir +"'" + "," + "'"+ ccode +"'" + ");");
}
catch(Exception exp)
{exp.printStackTrace();}
}
public Vector getData_detailspanel()
{
Vector vectordata=new Vector();
try
{
ResultSet resultset=stmt.executeQuery("Select * from pollingdetails;");
Vector vector;
while(resultset.next())
{
vector = new Vector(6);
vector.addElement(resultset.getString(1));
vector.addElement(resultset.getString(2));
vector.addElement(resultset.getString(3));
vector.addElement(resultset.getString(4));
vector.addElement(resultset.getString(5));
vector.addElement(resultset.getString(6));
vectordata.addElement(vector);
}
}
catch(Exception exp)
{exp.printStackTrace();}
return(vectordata);
}
public void saveData_detailspanel()
{
Vector basevector = mytablemodel.getDataVector();
int capacity = basevector.size();
try
{
stmt.executeUpdate("Delete * from pollingdetails;");
for(int index=0;index<capacity;index++)
{
Vector innervector = (Vector)basevector.elementAt(index);
stmt.executeUpdate("insert into pollingdetails values(" + "'"+ innervector.elementAt(0) +"'" + "," + "'"+innervector.elementAt(1)+"'" + "," + "'"+innervector.elementAt(2)+"'" + "," + "'"+innervector.elementAt(3)+"'" + "," + "'"+innervector.elementAt(4)+"'" + "," + "'"+innervector.elementAt(5)+"'" + ");");
innervector=null;
}
}
catch(Exception exp)
{exp.printStackTrace();}
basevector=null;
}
public Vector getData_polleddetailspanel()
{
Vector vectordata=new Vector();
try
{
ResultSet resultset=stmt.executeQuery("Select * from pollingstatus;");
Vector vector;
while(resultset.next())
{
vector = new Vector(7);
vector.addElement(resultset.getString(1));
vector.addElement(resultset.getString(2));
vector.addElement(resultset.getString(3));
vector.addElement(resultset.getString(4));
vector.addElement(resultset.getString(5));
vector.addElement(resultset.getString(6));
vector.addElement(resultset.getString(7));
vectordata.addElement(vector);
}
}
catch(Exception exp)
{exp.printStackTrace();}
return(vectordata);
}
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Record Operations for Tab2 & Tab3 @@@@@@@@@@@@@@@@@@@@@@@@@@ */
}
/* class "UserInterface" - end */
21 years ago
Dear All,
while loading this frame i am gettting the following error...
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Function sequence error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:4089)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:1902)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:1810)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java, Compiled C
ode)
at UserInterface.getData_polleddetailspanel(UserInterface.java, Compiled Code)
at UserInterface$PolledDetailsPanel.<init>(UserInterface.java:374)
at UserInterface.<init>(UserInterface.java:35)
at UserEntry$1.actionPerformed(UserEntry.java:107)
at java.awt.Button.processActionEvent(Button.java:308)
at java.awt.Button.processEvent(Button.java:281)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.ja
va, Compiled Code)
at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java
:95)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:90)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
i tried out all the combinations of function calling sequences...but still it is throwing the error....could any one pl. sort out the problem....
bye & waiting for ur reply,
Sakthivel S.

(edited by Cindy to format code . . . ALLLLLLL of it ).
[ November 12, 2002: Message edited by: Cindy Glass ]
21 years ago
Dear All,
I have a java program....and the compiled ".class" file for this....basically, it is a Frame..i will run this said program from my command prompt like,
C:\java megalaunch
...the frame will appear now....
what i want to know is .............Is it possible to change this said class file, in to an .exe file...so that, (instead of going for a command prompt for running the said program) i can just double click the said .exe file and start that said Frame....
pl. post a reply,
Sakthivel S.
21 years ago
yea,
thanks friend...thanks a lot!!! i did it finally...the changes i made for this to work are,
opening and closing the connection for each & every file....
second thing is, i am trying to send some dummy string from my server side, as follows...
String s="111";
ObjectOutputStream obj = new ObjectOutputStream(httpservletresponse.getOutputStream());
obj.writeObject(s);
obj.flush();
obj.close();
bye & have a nice day,
Sakthivel S.
21 years ago
Dear All,
Here is a strange problem....don't know how to solve this....
I am having two buttons in my JFrame....one is a "Start" Button. The other is a "Stop" Button....I have a global variable "decider" with value "1". Once if the start button is clicked, I am starting a for loop with 100 as the limit. Inside the for loop, i am undergoing some database connections and transactions....and also, i am checking, if the decider is "0", then break.....
/* ###Stopper### */
if(decider.equals("0"))
break;
/* ###Stopper### */
Once if the stop button is clicked, Iam trying to change the variable "decider" to "0". So, the for loop should get stopped abruptly....it is not happening as expected.....the for loop gets over for 100 times and then comes out....to be very clear, once if i click the "Start" button, the control goes to the Start button...(i mean a shadow)....only after the 100 times of for loop is over, the button "Stop is getting responded....
how to avoid this???
any suggestions/solutions are highly appreciated and welcome...
bye,
Sakthivel S.
21 years ago
Dear All,
I am trying to get authentication from my server, by using the below function...Here is a doubt...Once if my server is in "DOWN" state, i am getting the errors fired in my command prompt...how can i avoid this???.....i mean, i want to avoid the process of authentication, if the server is "DOWN"....how to find out whether a server is running in that url or not???

public String authenticateMe(String username, String password)
{
String setcookie="";
String cookie="";
try
{
URL theurl = new URL("http://192.168.10.55:8001/names.nsf?login&username=" + username + "&password=" + password);
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection hurl = (HttpURLConnection)theurl.openConnection();
hurl.connect();
setcookie = hurl.getHeaderField ("set-cookie");
if(setcookie!=null)
{
int index=setcookie.indexOf(";");
cookie=(setcookie.substring(0,index)).trim();
}
hurl.disconnect();
hurl=null;
}
catch(Exception exp)
{exp.printStackTrace();}
return cookie;
}

bye,
Sakthivel S.