How to execute MS Access Query using JDBC?

Reply

Join Date: Mar 2008
Posts: 3
Reputation: swdev is an unknown quantity at this point 
Solved Threads: 0
swdev swdev is offline Offline
Newbie Poster

How to execute MS Access Query using JDBC?

 
0
  #1
Mar 29th, 2008
dear all,

I know how to correctly execute SQL statement using con.execute() (where con is type of java.sql.Connection). But how can I execute Microsoft Access Query Object, which require one or more parameters?

Do we need to use PrepareStatement ?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,366
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How to execute MS Access Query using JDBC?

 
0
  #2
Mar 29th, 2008
Originally Posted by swdev View Post
dear all,

I know how to correctly execute SQL statement using con.execute()
No you don't, seemingly, since that's not right.

(where con is type of java.sql.Connection). But how can I execute Microsoft Access Query Object, which require one or more parameters?

Do we need to use PrepareStatement ?

Thanks
Statement, PreparedStatement, CallableStatement, whichever one is more suited to the task.
Read the JDBC tutorial.
Last edited by masijade; Mar 29th, 2008 at 9:06 pm. Reason: typo
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 3
Reputation: swdev is an unknown quantity at this point 
Solved Threads: 0
swdev swdev is offline Offline
Newbie Poster

Re: How to execute MS Access Query using JDBC?

 
0
  #3
Apr 2nd, 2008
I have manage to call Microsoft Access Query using CallableStatement, but there are still error regarding the Scroll Type (or whatever). I think it stuck, because I already made the scroll type to SCROLL_SENSITIVE/SCROLL_INSENSITIVE.

Any idea?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,366
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How to execute MS Access Query using JDBC?

 
0
  #4
Apr 3rd, 2008
I don't know that Access supports Scrollable ResultSets over the bridge, but I'm not sure, and can't really tel you more, because I, myself, don't use Access. I find it to be the worst DB choice available.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: How to execute MS Access Query using JDBC?

 
0
  #5
Apr 3rd, 2008
the bridge driver was created before scrollable resultsets were invented...
And of course using CallableStatement to access SQL (rather than call a stored procedure) is idiotic.

Kid, do as you were told and work your way through the JDBC tutorial.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 3
Reputation: swdev is an unknown quantity at this point 
Solved Threads: 0
swdev swdev is offline Offline
Newbie Poster

Re: How to execute MS Access Query using JDBC?

 
0
  #6
Apr 5th, 2008
Thanks for all.
My problems (they are really plural) were solved, because I switch to Access from the former MySQL. I need an environment where I can prototype a lot of database design fast,where at the same time, a fully functional code were developed.

At phase where I don't really understand the whole problem, MS Access really help me : I can design the database very fast. Now, when I need to switch to MySQL for example, I just use database converter utility.

Yes, I don't have any problem when using MySQL. Everything works fine. But, when I switch to Access, problems start to occur.

Isn't Acces Query not the same as Stored Procedure as in any RDMS such as MySQL? (as long as I can remember, using VB 6, I get my Access Query listed in Stored Procedure category when I use Data Report).

I will be really helped, if I can call that sets of Access Query. For now, I just make a Singleton that hold all of my Query Statement ( I copy pasted them from MS Access Query View), and call them using simple Statement such as this one :

String[][] data = DB.getInstance().getDataSet(ApplicationLogic.getInstance().getAllCluster());

where in ApplicationLogic.java there exist a static method that return String :

..
public String getAllCluster(){
return "SELECT SkorKlaster.ID, Klaster_1.Kode, Klaster_1.Nama, Klaster_1.Keterangan, Klaster.Nama, SkorKlaster.Skor
FROM PemakaiBerkas INNER JOIN (Klaster INNER JOIN (SkorKlaster INNER JOIN Klaster AS Klaster_1 ON SkorKlaster.Klaster2 = Klaster_1.ID) ON Klaster.ID = SkorKlaster.Klaster1) ON PemakaiBerkas.ID = Klaster.NamaBerkas
WHERE (((Klaster.Nama)='safety') AND ((PemakaiBerkas.NamaBerkas)='Bridge Selection'))";
}
...

Yes, those long SQL where copy pasted from Microsoft Acces. Maybe I can code it in MySQL Query Browser, but, I think that will be imposible as I work on a lot of database application at once.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC