Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!

Glyndwr Bartlett

Greenhorn
+ Follow
since Jul 30, 2018
I am not a programmer. I am learning as I go in order to create an award application for Scouts.
Australia
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
11
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Glyndwr Bartlett

Hi Tim Moores,

Yes, thank you. By removing getServletContext() from the ScoutMain.generateE1 and all reference to it in the called program it now works. If I can ever catch the person who produced the GWT version I will ask them why it was in there.

Kind regards,

Glyn

Hi Tim Holloway,

I understand the first three paragraphs of your reply; however, struggling with the last. I obviously need some education in this area; which I will see to.

Kind regards,

Glyn
1 week ago
I have an issue trying to use getServletContext() on the server-side. This is marked as an error (underlined in red) and the hover over error is "The method getServletContext() is undefined for the type MySQLConnection" and the quick fix is to create the mothod.

I am using some code that was generated by someone else for gwtJava. I am now trying to use this in a JEE project. Unfortunately I have not been able to get help from the person who originally created this code and I am not a programmer and am learning as I go.


The ScoutMain.generateE1 has:



I have looked at:

Different ways to get Servlet Context

Why getservletcontext isn't found?

And the getServletContext() documentation, which I found very confusing.

I think I may be missing an import; however, cannot find which one.

Kind regards,

Glyn
1 week ago
I am using Bootstrap 3 date picker. I am short of space and do not want to display the glyphicon. However, when I remove the glyphicon (i.e., the three span lines) the calendar picker is permanently displayed (instead of only when you click on the date field).

How can I set the code to only display the calendar picker when I click on the date field?

jQuery:



HTML:



Kind regards,

Glyn
This is what I ended up doing.

HTML:



jQuery:



SQL:

             
1 month ago
I need to store a pdf (each pdf will be < 5 pages maximum) in a mySQL database (yes I know this is not recommended). The column is defined as mediumblob. The test pdf is 198 KB. I get the error "Errors occurred in addMedicalPlan: java.io.FileNotFoundException: " followed by a dump of the file " JVBERi0xLjcKCjQgMCBvYmoKKElkZW50aXR5KQplbmRvYmoKNS ......" and at the end "(The filename or extension is too long)".

I have managed to do this with images and have been trying to re-purpose that code to store the pdf; by researching articles and other questions. Unfortunately, for me, most of the example relate to PHP. I have been able to read the pdf and display it in the page with this code:

HTML:



jQuery:



Do I need to strip off  "data:application\/(pdf);base64", i.e.,  img2 = (img1.getAttribute('src')).replace(/^data:application\/(pdf);base64,/, ""); for the pdf? I do similar for storing my images (i.e., img2 = (img1.getAttribute('src')).replace(/^data:image\/(png|jpg|jpeg|gif);base64,/, "");). Is this superfluous for pdf files?

I then pass the pdf to be stored with ajax:



And the server side java is:




I am not a programmer and am doing this pro-bono and learning as I go for my organisation.

Kind regards,

Glyn


2 months ago
Hi Carey,

My apologies I could not find the javascript forum. Can I transfer this or do I close it and create a new topic?

Kind regards,

Glyn
I am using jQuery/javascript to read in data from a spreadsheet using "xlsx.full.min.js" placing the data into a table and then validating the contents. Column 4 must be an unsigned integer, so I am using "RegExp("^\d+$")" to test for this. It always returns false even when a number is entered into the column in the spreadsheet that is imported.

Another issue is that the dates I enter are dd/mm/yyyy (e.g., 02/12/2018). However, the imported date is m/d/yy (e.g., 12/2/18).

The code is at: https://jsfiddle.net/Glyndwr/6z1ckv8y/2/

Sample input would be: "Paranoid", "Marvin", "01/09/1978", "42", "01/12/2018"
I found two errors:
1) grp_group should be grp_name
2)

should be:

I am using a prepared statement to try to insert a new row into the MySQL table and if the index exists perform an update. I am fairly sure that the issue is related to the "point" field labelled "grp_hall_geoPoint". I am receiving the error "SQLException in updateGroup: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'SET grp_country='Australia', grp_state='New South Wales', grp_region='Sydney Nor' at line 1"

The values being passed are:



The prepared statement is:



The following are in a unique index: grp_country, grp_state, grp_region, grp_district, grp_name, grp_section, grp_sub_section

grp_hall_geoPoint is type point

I have used test data to trigger the update and insert with the same result.



I am trying to add this validation to jQuery .validate:



Called at:



to check:



However, it is not being triggered (i.e., I am not getting the embedded alert an no error message displayed on the page when the field is empty, I also tried with content). There is no error message in the console.

Hi Dave,

I am hearing you brother. No 0 is not valid. :-)

Kind regards,

Glyn
Hi Tim H,

I posted a detailed reply and for some reason it is not here. I obviously failed to hit submit. Anyway, after completing the reply I was thinking (yes it did hurt) and did some further investigation and found "IFNULL". After some experimenting it worked. You deserve the credit for jogging this thought. Thank you for teaching me to fish.

For those interested the answer is to return 0 if null:



Kind regards,

Glyn
I really appreciate all the help you are providing. On another site I am getting sledged. Tim H you are totaly correct that this is very complexed so I have simplified it below. Knute I have tried your change with no difference. Tim C I am afraid the MySQL does not support "EXCEPT". Simplified:

This works:

   

This does not work:

   

Initially I only had the third "SELECT". I then added the second "SELECT" to check for "NULL" being returned by the third "SELECT". However, that did not correct the issue.

So "SELECT":
One returns the required values (all members not attached to an Account - not in the third "SELECT")
Two checks for "NULL" (i.e., no members currently attached to an Account - so return all members)
Three returns all members currently attached to the Account and therefore should be excluded from the list returned by the first "SELECT")

I am not a programmer, learning as I go and doing this for my Scouts.

Kind regards,

Glyn

I  am trying to create a list of members only if they are not in another list. When the other list has at least one member then the query works (member not in the other list are returned). However, when the other list contains no members (returns NULL) then no values are returned.

Carey,

Thank you so much for your help! The answer is:

As you said:



This is done before passing to java client side. Then on the server side:



Once again thank you very, very much.

Kind regards,

Glyn


5 months ago