• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ERROR: java.sql.SQLException: No data found

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
am trying to create a table in ms-access

but am getting this error while running the code


i have created the datasource name (userloginTable)
and created a driver (microsoft access driver(*.mdb))

can You please help me in this problem
Here is my code


/*
* Created on Jul 10, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.cts.dbconn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
* @author 133474
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class DBconn {
public static void main(String args[])
{






try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dataSourceName ="userlogintable";
String dbURL = "jdbc:odbc:" + dataSourceName;
Connection con = DriverManager.getConnection(dbURL, "","");
Statement s = con.createStatement();
s.execute("create table TEST(username integer,password char[6])");
s.execute("insert into TEST values(133484,'abc')");
s.execute("insert into TEST values(133474,'def')");
s.execute("insert into TEST values(133484,'ghi')");
s.execute("select username,password from TEST");
ResultSet rs = s.getResultSet();
if (rs != null)

while ( rs.next() )
{
System.out.println("Data from username: " + rs.getString(1) );
System.out.println("Data from password: " + rs.getString(2) );
}
s.close();
con.close();
}
catch (Exception err) {
System.out.println("ERROR: " + err);


}
}


}
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the create statement needs to be changed to as below,

"create table TEST(username integer,password text)"

and it will work. (text to be substitued in place of char[6])...

Regards
Ashwin
 
reply
    Bookmark Topic Watch Topic
  • New Topic