Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MS access SQL Exception

0 views
Skip to first unread message

Claudio Parnenzini

unread,
Apr 27, 2000, 3:00:00 AM4/27/00
to
Hi all,

I receive this error when i connect to a MsAccess database. ( I get the
result but i receive this 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.SQLFetch(JdbcOdbc.java:1250)
at sun.jdbc.odbc.JdbcOdbcResultSet.next(JdbcOdbcResultSet.java:1053)
at stonehagedb.mainFrame.jbInit(mainFrame.java, Compiled Code)
at stonehagedb.mainFrame.<init>(mainFrame.java:40)
at stonehagedb.stonehageDb.<init>(stonehageDb.java:12)
at stonehagedb.stonehageDb.main(stonehageDb.java:39)


Here is the code:

package stonehagedb;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.sql.*;
import java.io.*;

public class mainFrame extends JFrame
{
final static private String url = "jdbc:odbc:stonehagedb2";
final static private String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
final static private String user = "Admin";
final static private String password = "ready";
private Connection dbCon;

JPanel contentPane;
TitledBorder title;
JTabbedPane tabContainer = new JTabbedPane();
JPanel entitiesPan = new JPanel();
JTabbedPane entitiesSubPanel = new JTabbedPane();
JPanel lookupEnt = new JPanel();
JPanel insertEnt = new JPanel();
GridBagLayout gridBagLayoutEntLookup = new GridBagLayout();
JComboBox officeComboBox = new JComboBox();
JLabel entLab = new JLabel();
JLabel officeLab = new JLabel();
JLabel managerLab = new JLabel();
JButton submitButton = new JButton();
JComboBox managerComboBox = new JComboBox();
JTextField entTexField = new JTextField();
JComboBox entComBox = new JComboBox();

//Construct the frame
public mainFrame()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try{
jbInit();
}
catch(Exception e){
e.printStackTrace();
}
}

//Component initialization
private void jbInit() throws Exception
{
title = new TitledBorder("");

contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(null);
this.setSize(new Dimension(656, 654));
this.setTitle("Stonehage Db");
title.setTitle("coucou");
tabContainer.setToolTipText("");
tabContainer.setBounds(new Rectangle(-4, 0, 650, 644));
entitiesPan.setToolTipText("");
entitiesPan.setLayout(null);
entitiesSubPanel.setBounds(new Rectangle(16, 8, 612, 594));
lookupEnt.setLayout(gridBagLayoutEntLookup);
entLab.setText("entities");
officeLab.setText("Office");
managerLab.setText("Manager");
submitButton.setHorizontalTextPosition(SwingConstants.CENTER);
submitButton.setText("Submit");
entComBox.setToolTipText("");


contentPane.add(tabContainer, null);
tabContainer.add(entitiesPan, "entities");
entitiesPan.add(entitiesSubPanel, null);
entitiesSubPanel.add(insertEnt, "Insert");
entitiesSubPanel.add(lookupEnt, "lookupEnt");
lookupEnt.add(officeComboBox, new GridBagConstraints(1, 3, 1, 1, 0.0,
0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 50, 0));
lookupEnt.add(officeLab, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 20, 0));
lookupEnt.add(managerLab, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 20, 0));
lookupEnt.add(submitButton, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new
Insets(18, 1, 31, 1), 0, 0));
lookupEnt.add(managerComboBox, new GridBagConstraints(1, 4, 1, 1, 0.0,
0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 50, 0));
lookupEnt.add(entLab, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 20, 0));
lookupEnt.add(entTexField, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new
Insets(-1, 0, 0, 0), 150, 0));
lookupEnt.add(entComBox, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 50, 0));
entitiesSubPanel.setSelectedComponent(lookupEnt);

createConnection();
Statement stmt = dbCon.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM offices");
while(result.next()){
officeComboBox.addItem(result.getString("office"));
}

stmt.close();

stmt = dbCon.createStatement();
result = stmt.executeQuery("SELECT * FROM managers");
while(result.next()){
managerComboBox.addItem(result.getString("manager"));
}
stmt.close();
closeConnection();
}

//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}

}

private void createConnection(){
try{
//Download the Driver JDBC pipe to ODBC
Class.forName(driver);
dbCon = DriverManager.getConnection(url,user,password);
}
catch(ClassNotFoundException cnfex){
// process ClassNotFoundExceptions here
cnfex.printStackTrace();
System.out.println( "Connection unsuccessful\n" + cnfex.toString() );
}
catch ( SQLException sqlex ){
// process SQLExceptions here
sqlex.printStackTrace();
System.out.println( "Connection unsuccessful\n" + sqlex.toString() );
}
catch ( Exception excp ){
// process remaining Exceptions here
excp.printStackTrace();
System.out.println( excp.toString() );
}
}

private void closeConnection(){
try{
dbCon.close();
}
catch(Exception e){
System.out.println(e);
}
}
}


Stefan Zschocke

unread,
Apr 27, 2000, 3:00:00 AM4/27/00
to
you might have to change your statement to "select office from offices"
instead of "select * from offices".
jdbc-odbc-bridge is kind of tricky to use you have to access column-values
in a certain sequence and not revisit a column of the same row and so on.
BTW, you might try our driver, it works better.
Stefan
(http://www.infozoom.de/javaado.html)

"Claudio Parnenzini" <cla...@stonehage.com> wrote in message
news:8e9k0p$t7i$1...@news.worldcom.ch...

> file://Construct the frame


> public mainFrame()
> {
> enableEvents(AWTEvent.WINDOW_EVENT_MASK);
> try{
> jbInit();
> }
> catch(Exception e){
> e.printStackTrace();
> }
> }
>

> file://Component initialization

> file://Overridden so we can exit when window is closed


> protected void processWindowEvent(WindowEvent e)
> {
> super.processWindowEvent(e);
> if (e.getID() == WindowEvent.WINDOW_CLOSING)
> {
> System.exit(0);
> }
>
> }
>
> private void createConnection(){
> try{

> file://Download the Driver JDBC pipe to ODBC

0 new messages