Solved

SQLException: No data found

Posted on 1998-11-28
7
958 Views
Last Modified: 2009-12-16
Im trying to create the following table (taken from Sun's tutorial on JDBC)
Im trying to use MS Access on a Windows 95 machine and have JDK1.2rc2
Heres what Ive done so far:
--Went to Control Panel (Windows95)
--clicked on 32bit-ODBC
--added a data source on MSAccess Driver
--set up the data source name -- "test" and gave it a description
--clicked advanced and gave it a login name and password ("test" -- "test")
I then compiled the source below and tried to run it
The error message was:
SQLException: No data found

I also tried to set the the driver for the data source to be SQL Server and got SQLException: SQL server not found

import java.sql.*;

public class CreateCoffees {
    public static void main(String args[]) {
        String url = "jdbc:odbc:test";
        Connection con;
        String createString;
        createString = "create table COFFEES " +
                            "(COF_NAME VARCHAR(32), " +
                            "SUP_ID INTEGER, " +
                            "PRICE FLOAT, " +
                            "SALES INTEGER, " +
                            "TOTAL INTEGER)";
        Statement stmt;

        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }

        try {
            con = DriverManager.getConnection(url,"test","test");
            stmt = con.createStatement();
            stmt.executeUpdate(createString);
            stmt.close();
            con.close();

        } catch(SQLException ex) {
            System.err.println("SQLException: " + ex.getMessage());
            System.err.println("SQLState: " + ex.getSQLState());
        }
    }
}

I read in the locked questions the following:
"In case of sun jdbc-odbc bridge for java applications you don't have to install anything on webserver
but the problem is thats not available for MS Access."  -- Arooj
Is this the reason for my problem or am I taking this out of context?
0
Comment
Question by:conick
  • 4
  • 2
7 Comments
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
i tried your example
- created Datasource "test", user "test", password "test"
(chosing new Database - so creating new .mdb file)
- copy & paste your java code
- compile it and run it

and everything worked OK
i have new table COFFIES with 5 columns in my .mdb file

tested on WinNT, jdk1.1.7A, MS Access 97, Access ODBC driver version 3.50.360200,

and i've never experienced such problems ... maybe you haven't configured the ODBC datasource or you have older ODBC driver ???

more help needed ?
  heyhey

P.S.
>>   I also tried to set the the driver for the data source to be
>>  SQL Server and got SQLException: SQL server not found
it seems that ODBC driver works, but it can't find thge SQL server, if you can see this DataSource from Access, it should be possible to see it from Java
(Access / Create new Database / Get External Data / Link Tables then chose "file of types" ODBC Databases.)
0
 
LVL 27

Expert Comment

by:BigRat
Comment Utility
Just a small thing from a silly mouse like me. I don't have my JDBC manualy with me, but is "stmt.executeUpdate(createString);" the correct call for creating a database table?

0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
BigRat:
>> Just a small thing from a silly mouse like me.
maybe you are Big, but you are not silly :))

yes "stmt.executeUpdate(createString);" is the correct statement
>> public abstract int executeUpdate(String sql) throws SQLException
>> Execute a SQL INSERT, UPDATE or DELETE statement.

and it even works :) (on my system :)

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Author Comment

by:conick
Comment Utility
Im running the following:
MSAccess for Windows 95 version 7.00
ODBC Driver:       3.50.342800    odbcjt32.dll   12/4/96
So it is an older ODBC driver.. but the Access version is also older
Maybe this is the problem??

I tried to see the data source from Access and I could (under Machine Data Sources not File Data Sources)

I never set up an initial database before I ran the java code... Do I need to do something in Access before I run it?
I have since set up "test.mdb" and tried to run it.  No dice.

This is incredibly frustrating...
Raising points to 100

<Warning: here comes a vent>
Does anyone else get upset when you read help files and it uses tons of acronyms that you dont know what they stand for?
<end vent>

0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
hmmm ...
and i'm using 'only' jdk1.1.7  - maybe this is the problem :-)

add 'pint stack trace' line in the exception handler
  System.err.println("SQLException: " + ex.getMessage());
  ex.printStackTrace();
  System.err.println("SQLState: " + ex.getSQLState());

you'll see the file and line number where exception occures ... (post this information here). probably you can decomile these classes (if they don't come with sources) and see what is the exact problem (of course if the problem is in the bridge, not in the ODBC driver itself)

hope this helps
  heyhey

P.S. i just saw this line
>>  never set up an initial database before I ran the java code...
i think that you NEED to set .mdb database when you create the datasourse, so that the ODBC driver has some physical object to act over ...
0
 
LVL 7

Author Comment

by:conick
Comment Utility
AHHHH  HAA!
eurika!

As you said you need to have a physical object for the driver to act on...
I created the *.mdb in Access and did not assign it to the datasource

In other words: I created the data source but didnt give it a file to act on
(in the control panel)
I needed to click on either <Create> or <Select> to configure the database for the data source
which I didnt do
post an answer and ill give ya an "A"
Thanks!
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
Comment Utility
:)
it was on the third line

>> tried your example
>> - created Datasource "test", user "test", password "test"
>>> (chosing new Database - so creating new .mdb file)

best regards
  heyhey
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now