Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regexpression in a preparedStatement

843859Mar 31 2008 — edited Mar 31 2008
Hey folks,

I am trying to do the following on a MySQL 5 DB to select entities beginning with a certain number.
psSelectRegex =connection.prepareStatement(
					"SELECT * FROM artikel where artikel_nr regexp '^?' ORDER BY artikel_nr LIMIT 0,25"
			);
psSelectRegex.setString(1,iartikel_nr);
psSelectRegex.executeQuery();
As an unprepared Statement in the following form it works perfectly.
"SELECT * FROM artikel where artikel_nr regexp '^" + iartikel_nr + "' ORDER BY artikel_nr LIMIT 0,25"
The error i get is: Parameter index out of range (1 > number of parameters, which is 0).

How do i solve this to use the regexp??

Thanks in advance

Best regards

Oliver
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 28 2008
Added on Mar 31 2008
2 comments
447 views