| Author |
ERROR: java.sql.SQLException: No data found
|
rakshini nithya
Ranch Hand
Joined: Jun 15, 2006
Posts: 39
|
|
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 dbc:" + 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
Joined: Jun 14, 2006
Posts: 43
|
|
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
|
 |
 |
|
|
subject: ERROR: java.sql.SQLException: No data found
|
|
|