WebFaction
Community site: login faq

Hi, I'm trying to send some data to my webfaction mysql database from my java program running on tomcat server at webfaction

 Class.forName("com.mysql.jdbc.Driver");
    Connection conn = null;
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/stegzzz?user=stegzzz&password=mypassword");
   String query=String.format("insert into ddprz (request, response) values (%s,%s)",request,result);
   PreparedStatement pst=conn.prepareStatement(query);
   pst.execute();
   conn.close();

The rest of the program works OK and this code works fine from my desktop machine to a local database, can anyone see what I'm doing wrong here?

Thanks, Steve

asked 28 Oct '16, 20:46

stegzzz
17716
accept rate: 66%

What sort of problem are you seeing when you run that code?

(28 Oct '16, 23:48) seanf

Thanks Sean, I was seeing the database did not update and was focussing on the getConnection command which produced no error but neglected to investigate statement execution. Your question prompted me to look and the fault was in the String I was sending.

(29 Oct '16, 10:43) stegzzz

See my response to seanF's comment

permanent link

answered 29 Oct '16, 10:49

stegzzz
17716
accept rate: 66%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×168
×22
×16

question asked: 28 Oct '16, 20:46

question was seen: 1,771 times

last updated: 29 Oct '16, 10:49

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM