Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-01-2008, 02:12 PM
Member
 
Join Date: Feb 2008
Posts: 1
austinsmiles is on a distinguished road
Plz help ... retreiving data from an access database table....
i think there is some problem with the execute query statement.......
plz help...




import java.sql.*;
import java.io.*;

public class new2
{
public static void main(String args[])
{
if(args.length!=1)
{
System.out.println("syntax:give filename");
return;
}
java.sql.Connection conn = null;
try
{
conn=AccessJDBCUtil.getAccessDBConnection(args[0]);
Statement stmt = conn.createStatement();
ResultSet rs=null;
//stmt.execute(args[1]);
rs=stmt.executeQuery("select name2 from table1 where name1=derik");
//outputResultSet(rs);
stmt.close();
}
catch(SQLException s)
{
System.out.println(s);
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch(SQLException ignore) {}
}
}

}
/*private static void outputResultSet(ResultSet rs) throws SQLException
{
ResultSetMetaData rsMetaData=rs.getMetaData();
int numberofcolumns=rsMetaData.getColumnCount();
while(rs.next())
{
for(int i=1; i<(numberofcolumns+1); i++)
System.out.print(rs.getString(i) + " ");
System.out.println();
}
rs.close();
}*/
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-01-2008, 02:21 PM
jelly's Avatar
Member
 
Join Date: Jan 2008
Location: Somerset, UK
Posts: 46
jelly is on a distinguished road
Assuming name2 is declared as varchar it will require string to be passed in the where clause, try:

Code:
rs=stmt.executeQuery("select name2 from table1 where name1='derik' ");
If that doesn't work then please post what the failure is that you are getting
__________________
-- Hope that helps
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with jTable that is binded with a table in MySQL Database rajkenneth NetBeans 0 03-29-2008 04:36 PM
Deleting records from database table using PreparedStatement Java Tip Java Tips 0 02-09-2008 09:31 PM
Modifying data in database table using PreparedStatement Java Tip Java Tips 0 02-09-2008 09:22 PM
Upload excel data to access database ravikumar.achi New To Java 0 11-12-2007 02:52 PM
Help with access a database using Microsoft Access cachi Database 1 08-07-2007 08:51 AM


All times are GMT +3. The time now is 10:03 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org