Link to home
Start Free TrialLog in
Avatar of TLTEO
TLTEO

asked on

SQL syntax

For small size field, I use

PreparedStatement stmt = null;

sql = "UPDATE myrecord file"
         +" WHERE catalog=?";

  stmt = theConn.dbConn.prepareStatement(sql);
  stmt.setString(1, strA);
  stmt.setString(2, cataname)

this works for filed size smaller than 255 in MS ACCESS, when I refer to a string.

What if I wish to insert a file about 600 characters long.


What do I use ... stmt.set ..?? cos I am getting this error

java.lang.ArrayIndexOutOfBoundsException

.

Avatar of plrf
plrf

In the database, maybe would to make changes. I am not sure that the type Ms Access'  TEXT support more that 255 characters. Verify that.

  the rest is Ok. Probe it.

  stmt = theConn.dbConn.prepareStatement(sql);
  stmt.setBytes(1, strA.getBytes());

  this would work.

  good luke.
Avatar of TLTEO

ASKER

In MS ACCESS  I have to use memo field.  Because Text onlt support up to 255 characters.

woudl this be able to do it?

Avatar of TLTEO

ASKER

I am getting this error

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value

        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
        at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBinary(JdbcOdbc.java:714)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setBinary(JdbcOdbcPreparedSta
tement.java:2911)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setBytes(JdbcOdbcPreparedStat
ement.java:797)

If you field is memo, then use this


stmt = theConn.dbConn.prepareStatement(sql);
stmt.setClob(1, strA);

  that is all.



Please refer

                   http://groups.yahoo.com/group/xml-dbms/message/113
Avatar of TLTEO

ASKER

strA must be a Clob.  How do I set a string to a Clob??
No problem. Use String (java class). The compiler won't generate  an error.

  Declare

  String strA="";

 

  bye.
Avatar of TLTEO

ASKER


I am still getting this error when I conpile

setClob(int,java.sql.Clob) in java.sql.PreparedStatement c
annot be applied to (int,java.lang.String)
  stmt.setClob(1, strA);
      ^
I am just declaring String strA="";
ASKER CERTIFIED SOLUTION
Avatar of plrf
plrf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi kotan,
  If I used the database specified JDBC driver instead of using JDBC-ODBC, I could avoid the error ??
TLTEO:

You have many open questions:

https://www.experts-exchange.com/jsp/qShow.jsp?qid=20077765
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177485
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20178630
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177653
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20235670
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177859
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20250974
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20148640

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/4