Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pl. help me...

 
sakthivel shan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 */
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic