Solved

SQLException: No data found

Posted on 1998-11-28
7
961 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_
ID: 1228363
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
ID: 1228364
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_
ID: 1228365
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Author Comment

by:conick
ID: 1228366
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_
ID: 1228367
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
ID: 1228368
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
ID: 1228369
:)
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
json example 39 132
eclipse argument 14 53
jar file executable 12 40
how to add new optional parameter to JSP 1 27
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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:

910 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

19 Experts available now in Live!

Get 1:1 Help Now