• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ERROR: java.sql.SQLException: No data found

 
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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 = "jdbcdbc:" + 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);


}
}


}
 
Ash Kondhalkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic