Validation of non alphanumeric chars in a JavaBean method

Hello people,
does anyone have any tips on writing a method for a Java Bean that can take in a String param and check to see if it contains chars such as ' or " (quatation or double-quotation marks).
I need to preferably be able to convert them to enable their insertion to an SQL statement, writing to a database, or to strip them out.
I'm sure a lot of you know the problems of inserting these types into SQL to write to a db....
I realise that Perl or perhaps Javascript could do this, but I want to use server-side Java.
Thanks
Mike

I want to be able to insert Strings such as: "the
coursework's mark was 90%" - including the '
(apostrophe), but SQL won't let you do that, I get an
error in the SQL query execution.That's funny, I can insert those characters directly into a MySQL database using JDBC and a PreparedStatement. The SQL I'm using let's me do precisely that, percent signs and apostrophes included... :)
String dataString = "the coursework's mark was 90%";
String sql = "INSERT INTO table (column1) VALUES (?)";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, dataString);
ps.executeQuery; // inserts apostrophe and percent sign
                 // without a problem...

Similar Messages

  • Validation for Non-AlphaNumeric characters

    Hi All,
    I want to do Validation for Non-Alpha Numeric characters.
    While saving record, Name should only allow alphanumeric(letters and numbers only) characters, No special characters.
    How to do this?
    Plz help
    Thanks,
    Sk

    SK
    In EOImpl file in setter method of Name you can write below logic
    import java.util.regex.*;
      public void setLastName(String value)
        Pattern p = Pattern.compile("[^a-zA-Z0-9]");
        Matcher m  = p.matcher(value);
            if (m.find()){
                System.out.println("last Name"+value);
                throw new OAException("Special Characters Not allowed in Name", OAException.ERROR);
           setAttributeInternal(LASTNAME, value);
      } Hope it helps!!!!
    Thanks
    AJ

  • Non-alphanumeric chars replaced with underscore when saving long filenames

    Hi,
    I have a java application that streams a byte array (content type: 'application/pdf') to an Internet Explorer window. The PDF displays fine, in an embedded version of Adobe Reader 8. However, if I click on the Adobe 'Save' button then the filename gets changed as follows:
    PDF URL: http://localhost:8080/mcs/ctrl/flowOpenJobPDFWindow/AP1070.pdf?veryLongQueryString...
    PDF filename: http___localhost_8080_mcs_ctrl_flowOpenJobPDFWindow_AP1070.pdf
    Anything that isn't alphanumeric is converted into an underscore character. I would expect, and need, the file to be named something like 'AP1070.pdf'.
    I think this has something to do with the fact that I am streaming content to IE because if I point an IE window to an identical file that actually exists on the server then the filename when saving does look like 'AP1070.pdf', regardless of the length of the URL or querystring. Does adobe reader expect something in the header to stop this happening?
    I can provide java code if this would be useful, or any other information required. If you think this is more likely to be a java issue then I thank you for your time and will raise on a java forum.
    Environment:
    Windows XP Professional Version 2002 Service Pack 2.
    Adobe Reader 8.
    Internet Explorer 7.0.5730.11
    Many thanks,

    You can give feedback to Apple at their Feedback Page.

  • Sqlloader -350   illegal combination of non alphanumeric character

    hi all,
    i'm using owb 10.2.0.1
    i have a file in my D:\2122008.txt and a table in oracle DB
    created a map from file to table.....
    generated a code and saved in D:\orahome_1\owb\codegen\ctl\Employee.ctl
    deployed in target database...
    when is start from OWB i get the following error
    RPE-01013: SQL Loader reported error condition, number 1.
    SQL*Loader: Release 10.2.0.1.0 - Production on Thu Mar 6 17:50:01 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    SQL*Loader-500: Unable to open file (d:\EMPLOYEE.ctl)
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: The system cannot find the file specified.
    so i planned to run by invoking sql*loader..
    this is the generated code
    OPTIONS (BINDSIZE=50000,ERRORS=50,ROWS=200,DIRECT=TRUE,READSIZE=65536,FILE='F_21022008_TXT')
    CONTINUE_LOAD DATA
    CHARACTERSET WE8MSWIN1252
    INFILE '{{FILE_EMP_LOCATION1.RootPath}}{{}}21022008_TXT'
    DISCARDMAX 0
    CONCATENATE 1
    INTO TABLE "DMT_ADMIN"."AZBJ_ONEEMPLOYEE_DATABASE"@"dwhtest"
    APPEND
    REENABLE DISABLED_CONSTRAINTS
    FIELDS TERMINATED BY X'09' OPTIONALLY ENCLOSED BY 'X' SKIP 0
    "REC_SRNO" POSITION(1) INTEGER EXTERNAL ,
    "EMPLOYEENUMBER" INTEGER EXTERNAL ,
    "EMPLOYEENAME" CHAR ,
    "EMPDOB" CHAR ,
    "GENDER" CHAR ,
    "DEPARTMENT" CHAR ,
    "DESIGNATION" CHAR ,
    "OPUSCODE" CHAR ,
    "BRANCHCODE" CHAR ,
    "OFFICEMAIL" CHAR ,
    when i execute in sqlldr it is openeing the ctl file but gives the following error
    sql*loader-350: syntax error at line 21
    illegal combination of non-alphanumeric characters
    INTO TABLE "DMT_ADMIN"."AZBJ_ONEEMPLOYEE_DATABASE"@"dwhtest"
    the error is comming at the symbal "@"
    tried out several ways but could'nt resolve the prob
    anyone out there to help me....

    shld i need to keep the source files where OWB server is installed or can i run the process by keeping the files in my client systems local directory?

  • "Schema validation found non-data type errors" error when passing a string value to date field in infopath

    Hi,
    I have an infopath web brower enabled form. In the form i have a date field.
    I am passing the data from the database to that field using the C# code.
    But, as the field from database is coming as string, i am getting an error, and i am not able to assign the value.
    I get the date value from database as "3/25/2011 12:00:00 AM"
    I used the below code:
    [CODE]
    if (objInfopathFormcData.myRecievedDate != null)
      myRoot.SelectSingleNode("/my:myFields/my:field97", NamespaceManager).SetValue(objInfopathFormcData.myRecievedDate);
    [/CODE]
    I am getting the error as "Schema validation found non-data type errors".
    How to set the value for a date field in Infopath.
    Thank you

    HI,
    I fixed it:
    Below code is used to fix:
    [CODE]
    XPathNavigator xfield = null;
    DateTime dtmyRecievedDate;
    dtmyRecievedDate = Convert.ToDateTime(objInfopathFormcData.myRecievedDate);
    if (objFormcData.FcCompletionDate != null)
    xfield = myRoot.SelectSingleNode("/my:myFields/my:field97", NamespaceManager);
    DeleteNil(xfield);
    xfield.SetValue(dtmyRecievedDate.GetDateTimeFormats().GetValue(5).ToString());
    // method to delete xsi:nil
    private void DeleteNil(XPathNavigator nav1)
    if (nav1.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
       nav1.DeleteSelf();
    [/CODE]
    Thank you

  • Map binary data (PDF) to XML not possible due to non-printable chars

    Hi XI Gurus,
    we have the following issue.
    We send a PDF as binary data (as a hex string '25255044462D3' ) along with some other information from ERP within one RFC to XI , doing a message split 1:n for those two kind of messages (1. the PDF, 2. the XML) an send the split messages to file/ftp receiver adapter.
    The message split and sending of the messages is working well, but we encounter some problems with non-printable chars (hex code below 0x20) in the pdf binary. The PDF data and the dynamic file name is mapped into an XML. But the non printable characters are converted into '#' when mapped into the XML target field.
    (Due to the 1:n multi mapping, we cannot put the filename into dynamic configuration, so we have to map the pdf and the filename into an XML and extract the content with variable substitution in receiver file adapter....)
    My question is: how can binary data with non-printable chars be sent through XI and can be mapped into an XML without beeing replaced by '#' ?
    Any help will be greatly appreciated.
    Thanks and regards
    Holger

    Maybe I didn´t explained it clearly enough.
    We do not have the issue that the RFC puts the '#' into the string. We got from the RFC a hex string containing the pdf as visible hex values like:
    As you can see we have the pdf as hex string. During message mapping XI replaces some non-printable chars like '0x04' or '0x19' with '#'.
    My question is: how can we avoid those char replacement ?
    BTW: I grabbed a pdf with sender file adapter, routed through XI without any mapping and send it with ftp in binary mode. But the pdf contains more chars as the origional file and the pdf content is not visible when opening with a pdf reader like Acrobat. I guess the file adpter has problems with carriage return and linefeed chars. Some CR and LF are replaced inserted somehow.
    Best regards,
    Holger

  • Folders that having non-ascii chars are not displaying on MAC using JFileChooser

    On MAC OS X 10.8.2, I have latest Java 1.7.25 installed. When I run my simple java program which allows me to browse the files and folders of my native file system using JFileChooser, It does not show the folders that having non-ascii char in there name. According this link, this bug had been reported for Java 7 update 6. It was fixed in 7 Update 10. But I am getting this issue in Java 1.7.21 and Java 1.7.25.
    Sample Code-
    {code}
    public class Encoding {
    public static void main(String[] arg) {
    try {
    //NOTE : Here at desktop there is a folder DKF}æßj having spacial char in its name. That is not showing in file chooser as well as while is trying to read for FILE type, it is not identify by Dir as well as File - getting File Not Found Exception
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (IllegalAccessException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    Logger.getLogger(Encoding.class.getName()).log(Level.SEVERE, null, ex);
    JFileChooser chooser = new JFileChooser(".");
    chooser.showOpenDialog(null);
    {code}

    Hi,
    Did you try this link - osx - File.list() retrieves file names with NON-ASCII characters incorrectly on Mac OS X when using Java 7 from Oracle -…
    set the LANG environment variable. It's a GUI application that I want to deploy as an Mac OS X application, and doing so, the LSEnvironment setting
    <key>LSEnvironment</key> <dict> <key>LANG</key> <string>en_US.UTF-8</string> </dict>

  • [SOLVED] Non english chars kdemod 4 problem

    Hello, I have a little problem with KDE and the non english charactes.
    If I open a file with non english chars in its name I get something like this:
    (In this case kwrite opens "other" file but in other applications it fails with an error of file not found)
    Other sympton is that in KDE menu my name have bad chars too:
    (It must be López)
    And the third sympton is that if try to rename a file in the desktop, I can't write accented chars (á é í ó ú). At the begining the keyboard in this rename dialog was totally in english but i have got a semi spanish keyboard (i can write ñ letters) with the apropiate /etc/hal/fdi/policy/10-keymap.fdi file.
    But the most strange is that in general, in all Kde and non-kde applications and even in the console, non english chars works ok. I can go to the file->Open menu of the application and open a file with non english chars in its name. The problem seems to reside in the part of kde that passes the name of the file to the application (¿kwin?)
    my locale is es_ES@UTF8 and as I said I have configured correctly the 10-keymap.fdi file.
    I have read in some forums that something like this could be a kde or qt bug, but for me it's not clear as i don't see a general complaining about this.
    Any idea will be apreciated.
    Thanks in advance,
    Christian.
    Last edited by christian (2009-03-27 14:52:17)

    SanskritFritz wrote:
    That should be "es_ES.utf8"
    Sorry, i mispelled it in the post.
    Of course, my locale is es_ES.utf8:
    LANG=es_ES.utf8
    LC_CTYPE="es_ES.utf8"
    LC_NUMERIC="es_ES.utf8"
    LC_TIME="es_ES.utf8"
    LC_COLLATE=C
    LC_MONETARY="es_ES.utf8"
    LC_MESSAGES="es_ES.utf8"
    LC_PAPER="es_ES.utf8"
    LC_NAME="es_ES.utf8"
    LC_ADDRESS="es_ES.utf8"
    LC_TELEPHONE="es_ES.utf8"
    LC_MEASUREMENT="es_ES.utf8"
    LC_IDENTIFICATION="es_ES.utf8"
    LC_ALL=
    I don't think this could be the source of the problem, because, except in the places I said in the firs post, the rest of my system works perfectly.

  • How to load file thru reader which contains non-english char in file name

    Hi ,
    I want to know how to load file in english machine thru reader which contains non-english chars in file names (eg. 置顶.pdf)
    as LoadFile gives error while passing unicode converted file name.
    Regards,
    Arvind

    You don't mention what version of Reader?  And you are using the AcroPDF.dll, yes?
    Sent from my iPad

  • How can we do the validation for non visible records in table control.

    Hi Experts,
      I have a table control which displays list of material details. I have a button to upload the material details from excel file to table control directly. I have to validate all the customers which are exist in the table. But my item (Material) table control displays only 5 rows i.e only 5 entries are visible in module pool screen. The validation is done for 5 records only in PAI event, but i need to do validation for rest of the records too (Which are not visible on items table), if validation fails then needs to display error message.
      How can we do the validation for non visible records in table control.
    Regards,
    Bujji

    Hi,
    try validating material before displaying it in table control...'
    Rgds/Abhhi

  • UploadedFile and filenames with non-ascii chars

    Hi
    I'm using an UploadedFile object in my web app, and all works fine. However, when I try to upload a file, with a filename containing non-ascii chars (e.g. Spanish), I see that the getBytes method returns an empty byte array, the filename is not stored correctly (the non-ascii chars are lost, replaced by another representation), and that the content-type is application/octet-stream instead of image/png as supposed to be.
    If I rename that same file to have only ascii chars - everything is back to normal.
    How can I upload files with non-ascii chars in their name?

    Hi, back! Spent a few hours experimenting and found
    that everything is working great (including the creation
    of international non-ASCII foldernames) when I used
    utf-8 encoding in the sieve filters rules for the
    the match strings and the folder names... at least
    so far so good... for your ref and sorry for bothering.

  • Flash player will not play flvs from folder with name containing non-Roman Chars

    We're trying to play flash as part of a program that can be installed to locations including non-Roman chars (European, Arabic, Chinese, etc.).  When the installation path includes any non Roman chars, video will not play.  The non-roman chars are garbled when Flash tries to load the flvs. Correct non-Roman chars are: ńśćłł.  When loading video it gets translated to: ńśćłł
    We've found this happens whether we are trying to access the video from the xulrunner app or by taking the activities out and running them within an html frame.
    Audio on the other hand is no problem
    The path information for the xulrunner app from Process monitor is:
    Video not found from the video player.
    10:41:25.3337898    xulrunner.exe    2316    CreateFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\video\VI-d9e37af511faa\Engplus1.flv    PATH NOT FOUND    Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, AllocationSize: n/a
    10:41:25.3339452    xulrunner.exe    2316    CreateFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\video\VI-d9e37af511faa\Engplus1.flv    PATH NOT FOUND    Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a
    Audio found.
    10:41:59.7659648    xulrunner.exe    2316    ReadFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\audio\AU-fa6ed5d31f577\LG0CD1Track06.mp3    SUCCESS    Offset: 0, Length: 4,096, Priority: Normal
    10:41:59.7660482    xulrunner.exe    2316    ReadFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\audio\AU-fa6ed5d31f577\LG0CD1Track06.mp3    SUCCESS    Offset: 4,096, Length: 4,096
    Video not found from a flash interactive
    10:43:50.0804572    xulrunner.exe    2316    CreateFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\flash_interactive\content\FL-123456780l0l\assets\video\video. flv    PATH NOT FOUND    Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, AllocationSize: n/a
    10:43:50.0806413    xulrunner.exe    2316    CreateFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\flash_interactive\content\FL-123456780l0l\assets\video\video. flv    PATH NOT FOUND    Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a
    Audio found from a flash interactive
    10:43:50.1928413    xulrunner.exe    2316    ReadFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\flash_interactive\content\FL-123456780l0l\assets\audio\journa list.mp3    SUCCESS    Offset: 0, Length: 4,096, Priority: Normal
    10:43:50.1929148    xulrunner.exe    2316    ReadFile    C:\Pro\ńśćłł\Flash dll Test\.shared\content\assets\flash_interactive\content\FL-123456780l0l\assets\audio\journa list.mp3    SUCCESS    Offset: 0, Length: 25,206, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal

    Not exactly sure what you are doing, but it is obvious that some part of the program you are running does not support multibyte characters like Unicode.
    If you are developing that application, make sure it is Unicode enabled.  If it is Flash (or Flash Player) that doesn't understand it, then you may not be able to do anything about it.
    What I would try if I were to encounter the situation, I would try to use the DOS (8.3) path names, like C:\Documents and Settings would normally be C:\DOCUME~1 or C:\Documents and Settings\All Users would be C:\DOCUME~1\ALLUSE~1 etc.
    Use the DIR /X command to find out what the DOS folder names are.

  • Non-alphanumeric characters in textarea causing 404 errors

    I'm only just becoming acquainted with Coldfusion, as I've been asked to fix a problem in an existing system. The system consists of a simple html form containing a text area, among other input fields. The form is submitted to a cfm script, which displays a confirmation page and sends a couple of emails. The problem is that whenever the user enters any (as far as I can tell) non-alphanumeric characters, e.g. quotes, commas or brackets, in the textarea field, they get a 404 response from the server.
    I tried a number of things to identify the problem, including escaping the text in javascript before submission, but didn't get anywhere. The last thing I tried was installing a local version of the CF on my workstation, hoping to reproduce the problem and thus debug it more easily. However, on my local CF setup the problem does not occur.
    Can anyone help me debug this please? Thanks,
    Marcin

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • Java 5, Linux, 64-bit: Non-ASCII chars over socket

    Hi,
    I am having issues with reading non-ASCII chars from a socket. I send a mixed message, with the first part in ASCII and the last bit in non-ASCII. There are no issues with reading the non-ASCII characters on Windows. However, when I try running the server on Linux. The following is a message sample:
    Start message<CRLF>
    &#1092;&#1074;&#1072;&#1092;&#1099;&#1074;&#1072;&#1092;&#1074;&#1099;&#1072;&#1092;&#1099;&#1074;<CRLF>
    The second part (which is encoded in either Windows-1250 or KOI8-R), comes out as 3F (when you look at the bytes) on Linux.
    Any suggestions?
    Thanks,
    Max

    You must be using Readers and Writers, and you need to make sure you specify the same charsets when constructing them. Don't leave this to the default, as this seems to vary across platforms and definitely has varied across releases.

  • Select xmlelement of clob containing non-printable chars gives ORA-31011

    Using sqlplus against Ora9i database. We have some rows where the CLOB column contains non-printable chars because of a conversion from an old system.
    I'm trying to extract this data using xmlselect. Most of the time it works great, but for the above rows it dies with error:
    ORA-31011: XML parsing failed
    If I embed substr(columname,1,25) so that it doesn't get to the non-printable character (which is at about position 200), then the sql works great.
    Any ideas on how to massage this data, either on the fly, or I could do a one-time conversion. The problem is that darn CLOB. I can't even figure out how to find all the bad rows. Looking for sql to find the bad rows, or a function that I could put in a package, and then call from the select to convert it on the fly.
    thanks,
    Rick

    Thanks for your help. Anything I do (including your suggestion) to try and parse the xml bombs with an internal error. Without raising the exception.
    What I decided to do instead is do a search in the clob using instr(column, CHR(13)) but for also all CHR that are less than 32. I then replace it with a space. So I'm going to fix the data once rather than doing an on the fly fix.
    thanks again,
    Rick

Maybe you are looking for