Tom Reese

Greenhorn
+ Follow
since Apr 24, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tom Reese

Yeah I agree, my table has a sequence as a primary key, PostgreSQL increments it automatically for me. I will try to figure out something else instead of using rs.last(). Thanks for your input!
Well for a moment there I thought I would have to sacrifice a goat to get this working but I finally found a guide that told me exactly what I needed, the guide found here http://jdbc.postgresql.org/documentation/80/binary-data.html uses deprecated methods but simply find the most recent ones which simply use a long type variable instead of a int. Sometimes you just need the right documentation and examples in which my case I did. I understand how file uploading works and it doesn't seem so complicated. Thanks for the suggestions to modularize the code, it made it more readable and easier to understand. Here is my working code... and thanks to everyone who replied, sometimes you just need a little criticism and suggestions. Thread solved, case closed! Code is still lengthy but is much more readable I think. This will be going up on my website!

Ok after some very emotionally trying times I have arrived at a good place in my current code. I figured out the fix for getting around the Connection.createBlob() function. I found the solution here, http://www.xinotes.org/notes/note/943/ I also had to fix some other things revolving around getting the field values along with the file. The problem I am having now is simple, I am not reading in the file bytes correctly and I could some suggestions. I may be doing something really bogus because I have not messed with bytes a whole lot. To test if the bytes are being read I export the test file (small image) to a place on my disk. Currenty the file I export is empty. Sorry for the lengthy code...
I have done some head scratching and have ran into some issues. I can't use the method Connection.createBlob() because the Postgresql jdbc4 drivers do not support this, that is literally the error I am receiving. Here is my code currently...I am up for any other suggestions on how I can upload a file into my database. What other methods are out there? Thanks for any assistance you can provide.
Thank you for the suggestions, I think I am on the right track. I will debug and get a sense of whats happening. I will post my solution once i get it.
Hi JavaRanch,
My question is how would I upload a file, say a text file and insert it into my database. Firstly, I am aware that I need to use the Commons FileUpload from Apache. The only thing I could not find a example of was to use the Commons FileUpload in conjunction with a database. The code shown here... is what i have so far, I just don't understand where I should go on from here. I know that I need to convert the file into a Blob data type but how do I do that? Any help is greatly appreciated!
Thanks for the responses, always seem to be learning something new all the time.
11 years ago
Hi everyone,
I hate to start a new thread but I have not been able to find a solution to my problem. I am currently messing around with aws ec2 servers with suselinux environment. I am trying to deploy a web app but I am unable to because of my web-app cannot see the servlet-api.jar library. How do I set the class path permanently or temporarily so that I the web-app knows how to use servlets?
I have done a bit of digging around and one solution was to use the java -classpath command, which I never got to work, I also know that you can type set CLASSPATH=/usr/share/java/servlet-api.jar I am not sure how to get this to work either because everytime I tried to compile my java files they would still not compile even after trying this. I am feeling really lost on how to go about doing this. Any input would greatly help me, thanks!
-Tom R

nevermind just needed a more in depth guide http://www.yolinux.com/TUTORIALS/LinuxTutorialTomcat.html
11 years ago
Thanks a lot Martin, that worked, I was not familiar enough with how the PreparedStatement operated so that is why I had trouble with it. Thanks again!

By the way, what does the "||" operator do, i noticed that if I removed them that the sql failed, is that for the preparedstatement to parse?
Hello all,
I am currently trying to get these images out of this really simple database I created. The problem is I cannot get all of the images exported because some of the rows have name's such as, Bandit's Knife, notice the apostrophe. Everytime I try to export a image with a name that includes a apostrophe I will get a error, "Invalid sql syntax at or near s". Its a fairly small database with a couple hundred images or so. I thought that if I tried using a PreparedStatement instead that would help but I ran into another error, "The column index is out of range: 1, number of columns: 0". I also tried using the escape character that is mentioned here on the postgresql 9.1 docs I though that if I inserted the letter "E" in the correct place it would escape that single quote in the string but that did nothing. I really open to suggestions, here is what I have code wise.
Nevermind, my code is working fine except my ball logic is flawed, I viewed this applet on my desktop computer and it runs fine except the images need to be double buffered. Thanks anyways!

-Tom Reese
12 years ago
Howdy JavaRanch!
I have a small problem with a applet I have been tinkering around with. I am trying to get a ball to bounce around within the boundaries of the applet window, it works, well sort of...
My problem is this, when I call to repaint(); the images flicker too quickly or something and I cant see the images but they are moving. I can tell this because the ball flickers in and out of existence too quickly. When I dont call to repaint(); the ball/image sits there and does nothing, unless you resize the applet window, then it starts moving. I have two class files, one that paints and updates the applet, the other which is the Ball class controls all of the Ball like logic. Please let me know if you see a glaring problem, that would be nice. Thanks for looking at this stuff. I did do a search on these forums and tried to relate others code to mine but I dont see anything wrong with mine.
Thanks,
-Tom Reese
Here it goes..dum dum dum

13 years ago