Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
Inserting a 'weird' sentence into database
Arthur Buliva
Ranch Hand
Posts: 101
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello friends,
Consider this code snippet of mine:
String sentence = "My name is nameless aka 'anonymous' or \"anonymous\" ('did I hear that? Maybe!! now where were we?') -\"yawn! Am bored..."; PreparedStatement statement = connection.prepareStatement("insert into tenonly(name) values('" + sentence + "')"); statement.executeUpdate(); // THIS IS LINE 38
Also consider this stack trace:
init: deps-jar: Compiling 1 source file to /home/arthur/portal/MaintainTenEntries/build/classes compile: run: java.sql.SQLException: No value specified for parameter 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910) DONE at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1534) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1375) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303) at maintaintenentries.Main.main(Main.java:38) BUILD SUCCESSFUL (total time: 13 seconds)
All I want to do is to insert the sentence as it is into my database. Any help?
Muhammad Saifuddin
Ranch Hand
Posts: 1325
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
try this code.
PreparedStatement pstmt = connection.prepareStatement("INSERT INTO TENONLY (name) VALUES (?)"); pstmt.setString(1, sentence); pstmt.executeUpdate():
Saifuddin..
[Blog]
[Linkedin]
How To Ask Questions On JavaRanch
My OpenSource
Arthur Buliva
Ranch Hand
Posts: 101
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you very much for that. Works well
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Hibernate 3.0 : Where am I going wrong?
Syntax error while inserting a file into Mysql database.
problem with inser into query
Problem with Enums
Problem in using java to Store 1GB+ files in a MySQL database
More...