Patrick de Kruijf

Ranch Hand
+ Follow
since Mar 02, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Patrick de Kruijf

Many thanks for your quick replies and sorry my late one. I think you both send me in the right direction, but I think programming this is a bit out of my league. I'm gonna try anyway, I'll keep you informed on my findings.

Thanks again for your time and effort!

Patrick
12 years ago
Thanks for your help guys,

Sorry for my late reply, I always have to think about it for a couple of days to get it sorted out in my head . Yesterday I gave it a go and your idea works exactly like I hoped. Here is my solution, maybe I can help someone else with it who has the same question:

Class Frontend
Constructor method:

Adds jlabels and jtextfields to a jpanel, names for the labels are taken from a String array called Columns from another class called Core.



Class Core
String array declaration:

This String array is used for naming the jlabels in the frontend class, iteration (for loops) and other stuff.



Class Core
setDatabaseField method (combined setterMethod):

This method takes the JTextFields created in the constructor in the Frontend class and gets the text that is typed in the Frontend jtextfields for use in other methods. I use it in my code to store text that is typed by a user in different fields of a mysql database.



Thanks again for your help, time and effort, couldn't do it without you!
12 years ago
Hello there, I don't know if this is the right forum for my question, but here I am

I've been searching this forum, Google and the Googlemaps API but couldn't find the answer on my question.


Is it possible to write a java program that let's the user pick a location from Google Maps and store that location, as a postcode, in a MySQL database field? That way the users don't need to know the postcode, they can just pick the location from the map.

I only find discussions about displaying a postcode from a database in Google Maps. What I am looking for is the other way around.


Hope you can help me, thanks for your time and effort!

Patrick



12 years ago
Just wanted to say thanks, I couldn't get my query working the whole evening, but now it works!

Cheers,

Patrick

Sagar Dabas wrote:



Thanks for your idea, but I think that wouldn't work for two reasons:

1) OtherClass.setDatabaseField4(textField[i].getText()); needs to run when a 'save' button is pressed. Now OtherClass.setDatabaseField4(textField[i].getText()); only runs when the gui is build.
2) What about setDatabaseField1, setDatabaseField2, setDatabaseField3 ? How would I connect the the textField from the first iteration to the first settermethod, the textfield from the second iteration to the second settermethod etc ?
12 years ago
Hello there,

I hope you want to help me, because I can't figure this one out for myself.

I have a GUI with some JTextFields in it. I want to use text that is typed into the JTextFields as arguments for 4 different setter-methods of another class. That way I can store the textinput from the textFields into different columns of a database.

First I added the JTextFields, manualy, one by one like this:



After that I could connect the textFields to settermethods from another class like this:



Then I thought it was nicer to add the TextFields by iteration, so I deleted the code above and added the next code to my GUI class:



The code works, the JTextFields are added to my GUI. Problem is I don't know how to connect the 4 textField to my setter methods. I can't identify them by name or whatsoever, they are just called texField, and I can't reach them because the are inside the loop. How can I send the text typed in the 4 textField as an argument for my setter methods in the other class?

I've tried something like this, but I doesn't work:



Offcourse I can go back and delete the for loop and add the textFields one by one, but it just doesn't feel right.

Hope you can help me!

Thanks,

Patrick
12 years ago
Your right, exellent advice, thanks for your help and patience!

All the best wishes,

Patrick
Ok I think I think I understand: I thought the countSpots query only gave back an int for the counted rows, but it also shows a column for 'soort' (SELECT 'soort') am I right?

So if I'm right it is also possible to make a combination of the two statements? i.e.: "SELECT COUNT(*) FROM `spot` GROUP BY `soort`, `spotter`, `soort`, `datum`, `tijd` FROM `spot`";
Got a little further, but still problems with count statement. The statement displays the name of the bird and not how many times it was found in the column.

Here is my frontend:



Here is my core code:



And here is my SQL Connector

It does count the duplicate rows in the column `soort`and displays it in the Jlist, but only when there is only one of the same `soort`, (so no duplicate a all), it doesn't compile when I have 2 magpies in the column `soort`.

So if I have 1 Magpie my JList gets populated with data from resultOne and resultTwo, but when I add a row with another magpie it says "SQL error After end of result set".




I have changed to And now I get different errors , but not about the MySQL part of my code, Yay!
I have been searching the forum/net and changing my code for like 5 hours right now, but keep getting this error: java.lang.Exception: SQL foutmelding You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table group by soort' at line 1

I have changed my Vector into an arrayList, because I couldn't lRow .add(resultTwo.getint()); working with a vector, not that it helped, but I think lists are better anyway because I'm reading everywhere that Vectors have been deprecated since 1887. (Why does my teacher want me to use Vectors?).

This is the code I have so far, everything is working for resultOne, problems start when I want to add resultTwo at the end of every new row. Any help would be much appreciated, I had two days off to work on this assignment, I have learned a lot, but the code is pretty much still the same as it was at the beginning of this week

You got me there I went to fast with posting my translated code, I'm sorry for the confusion, but `soort` instead of `species` os not the problem in my code.

How can I display the statement count = "SELECT species, count(*) from table group by species"; in a JList?

I have this feeling that I have to use different code than for a statement like selectAllSpots = "SELECT `birder`, `species`, `date`, `time` FROM spot;"; Because the selectAllSpots statement is made from already existing fields in a database. The count statement is only a query on that database, there is no existing field called count, so I can't iterate trough the count statement like I can in the selectAllSpots statement, and resultTwo.getString(1)); doesn't make sense iether I guess.
Thank you very much, but I'm mostly interested in the the 'count column'. I'm able to display al the other columns in a JList just fine, but can't get the 'count column' working. Here is a part of my code, I think there is a problem with the count string and vRow.addElement(resultTwo.getString(1)); When I replace your `count` statement with a copy of the `selectAllSpots`, the program does compile, I don't know why.

I need to write a program for my school. It's an app for bird-watching-enthusiasts (don't know how you call them in English, we call them 'vogelaars').

The idea is that people who spot a specific bird-type, can add the name of that bird to the database. Furthermore the program needs to count how many birds of that type were spotted in total by the community. So the program needs to scan how many times that specific birdname, ie magpy, was entered in the column species.

After that I can try to display the statement with al the properties of a specific birdspot and the statement for the bird count in one JList row.

Hope I made it a little clearer, thanks for your time!