When DisableBind=0 the Update() function raise error:
invalid cursor state
if I set DisableBind=1 to the dbparm before I execute the Update() function then everything is fine and the data is saved.
What is the link between DisableBind and Invalid cursor state?
I have to use DisableBind=0, because I am savings Chinese characters into the DB. What should be the work around?
Environment:
PowerBuilder 12.5
ODBC 11
SQL Server 2008 R2
Not sure of the link between DisableBind and Invalid cursor state. But I used a temporary alternative as to set the disablebind parameter only where you need to save unicode characters. Ensure you do not have "disablebind" in your original connection string. If you do, please handle below script accordingly.
ls_dbparm = sqlca.dbparm
sqlca.dbparm += ',disablebind=0'
//process your saving code here
//once all saving done, very important to set it back
sqlca.dbparm = ls_dbparm
Related
I'm using multiple processes to write and read to an sqlite DB and am running into a busy error:Error: SQLITE_BUSY: database is locked.
Then I try to set the enableWAL parameter to true and the busyErrorRetry parameter to 300 milliseconds. Finally,When the problem occurs again,SQLITE_BUSY error will not be reported at this time,But the sqlite database seems to be locked.I don't know if retries are too frequent, which aggravates the problem.
I think the retry parameter busyErrorRetry is not a good behavior.I want to use the PRAGMA busy_timeout = parameter, but typeomr does not support it.
I am connecting to Firebird through IBX components in Delphi 10.2 Tokyo.
I'm trying to connect to the DB through the following code:
IBDatabase.Connected := False;
IBDatabase.Params.Clear;
IBDatabase.DatabaseName := FDBFileName;
IBDatabase.Params.Values['user_name'] := FDBUserName;
IBDatabase.Params.Values['password'] := FDBPassword;
IBDatabase.Params.Values['lc_ctype'] := 'UTF8';
IBDatabase.Connected := True;
By trapping the exception during connection, I can realize if the database does not exist, then I create it using the following code:
IBDatabase.Params.Clear;
IBDatabase.DatabaseName := FDBFileName;
IBDatabase.Params.Add('USER ''SYSDBA''');
IBDatabase.Params.Add('PASSWORD ''masterkey''');
IBDatabase.Params.Add('PAGE_SIZE 16384');
IBDatabase.Params.Add('DEFAULT CHARACTER SET UTF8');
IBDatabase.CreateDatabase;
The above operation creates the database and leaves the TIBDatabase component connected to the DB.
In this case, I am creating:
UTF8 string domains
Table with UTF8 field
and setting the Euro symbol (€) in it.
The app opens and the field is visible.
When I restart the app I constantly get an error:
No mapping for the Unicode character exists in the target multi-byte code page
I decided to write this post in order to share the solution I found after almost a week and sleepless nights.
The problem was generated by the creation of the database code.
Since parameters are different and from the usual connection parameters I put DEFAULT CHARACTER SET UTF8, believing that any DDL or statement I was going to operate in the database had the UTF8 character set.
This is not true, the database connection doesn't behave like the one with the lc_ctype parameter set.
To solve this I just had to close connection to the database, reset the parameters like I did the first time:
IBDatabase.Connected:= False;
IBDatabase.Params.Clear;
IBDatabase.DatabaseName:= FDBFileName;
IBDatabase.Params.Values['user_name']:= FDBUserName;
IBDatabase.Params.Values['password']:= FDBPassword;
IBDatabase.Params.Values['lc_ctype']:= 'UTF8';
IBDatabase.Connected:= True;
and do all the operations. This way it works properly.
I am working on an application built in Delphi 2010 that uses UIB to connect to a Firebird 2.5 database. The application has been running using the default character set for a long time, i.e. nobody gave character sets any special thought and it has simply been working. Currently I am trying to make it work correctly with UTF-8 data.
In doing so I have hit upon a problem with TUIBQuery and parameterized queries. When using Database.Charset=csUTF8 and setting a parameter value for a CHAR(n)-field and retrieving it before executing the query the value is truncated.
Unfortunately some of my code writes and reads parameter like this in a number of places and therefore dies an ugly death.
To isolate and demonstrate the problem I created a simple fresh database with DEFAULT CHARACTER SET UTF-8 and a table like this:
CREATE TABLE TEST (
CHARFIELD CHAR(20),
VARCHARFIELD VARCHAR(20)
);
I set up the application to connect to the database using TUIBDatabase and TUIBTransaction. Then I created a TUIBQuery-instance, set SQL to a parameterized INSERT-statement into this table, and set the parameters:
Query := TUIBQuery.Create(NIL);
Query.Transaction := Transaction;
Query.SQL.Text := 'INSERT INTO TEST (CHARFIELD, VARCHARFIELD) VALUES (:CHARFIELD, :VARCHARFIELD)';
Query.Prepare(True);
s:= 'ABC';
Query.Params.ByNameAsString['CHARFIELD'] := s;
Query.Params.ByNameAsString['VARCHARFIELD'] := s;
When I now read the parameter-values back like this:
s := Query.Params.ByNameAsString['CHARFIELD'];
s := Query.Params.ByNameAsString['VARCHARFIELD'];
The results are correct for Database.Charset=csNone. But when I instead specify DataBase.Charset=csUTF8 the value for CHARFIELD is truncated to 'A' instead of 'ABC'. The value for VARCHARFIELD is fine. The behaviour is independent of the actual data, I do not have to actually use non-ASCII-characters to provoke it, as the sample shows.
Calling ExecSQL() on the query works correctly and INSERTs the data as expected in both cases.
I have uploaded sourcecode to my simple test program as UIB_UTF8_Test.zip.
Does someone here have any idea what I may be doing wrong and how to do it right?
I am writing a telnet proxy on xp. Now I can telnet to system's telnet server and print its return values sending back to my procedure.
I find a very puzzling phenomenon. When I first telnet to the server,it will ask me to log in. I type in "tamlok", and I can see that it sending back to me that "116,97,109,108,111,107,10,13" which is the ascii value of "tamlok"(10 and 13 means '\n' and '\r').
However after I log in,I type in "tamlok" again. It sends back to me that "27,91,56,59,51,52,72,116,0,97,0,108,0,111,0,107,0,27,91,57,59,49,72".
I suggest that it returns the unicode so that "116" turns into "116,0" and so on. But I can't understand the sequence "27,91,56,59,51,52,72" and "27,91,57,59,49,72". I think it maybe a sequence for a special function, just like {0x1B, 0x5B, 0x48, 0x1B, 0x5B, 0x4A} will clear the console.
So,how to interpret this?
Any help is welcome!
Thanks to Joachim Pileborg.Now it is clear that it is terminal control codes. An example.
So "27,91,56,59,51,52,72" is "[Esc][8;34H" which suits the pattern:
Cursor Home [{ROW};{COLUMN}H
Sets the cursor position where subsequent text will begin. If no row/column parameters are provided (ie. [H), the cursor will move to the home position, at the upper left of the screen.
So does 27,91,57,59,49,72".
I'm making a web app that needs to load and save UTF-8 (Korean, specifically) characters from a DB. I've been given an account on the Oracle 10g server, but it saves VARCHAR2 type columns as ASCII7, with each UTF-8 character taking 2 VARCHAR2 slots.
I assumed that since iBatis is writing in the same way that it is reading, if I treat everything from input to output as UTF-8 I will have no problems, but any Korean characters I input come out garbled.
Is there a way to do this properly without messing up the (someone else's) DB?
Further information:
I've previously been able to load Korean strings using:
ResultSet rs = ps.executeQuery();
String koreanString = new String(rs.getBytes("colname"), "euc-kr");
And write Korean strings to db using:
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, new String(koreanString.getBytes("euc-kr"), "ISO-8859-1"));
Attempts to change the JDBC connection url result in this message:
Description
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
error dump
javax.servlet.ServletException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
at jeus.servlet.jsp2.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:859)
at jeus.servlet.jsp2.runtime.PageContextImpl.handlePageException(PageContextImpl.java:789)
at jeus_jspwork._jsp._500_managerAdmin_5fjsp._jspService(_500_managerAdmin_5fjsp.java:452)
at jeus.servlet.jsp2.runtime.HttpJspBase.service(HttpJspBase.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at jeus.servlet.jsp.JspServletWrapper.executeServlet(JspServletWrapper.java:147)
at jeus.servlet.servlets.JspServlet.execute(JspServlet.java:365)
at jeus.servlet.engine.HttpRequestProcessor.run(HttpRequestProcessor.java:284)
root cause
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.ibatis.common.jdbc.SimpleDataSource.popConnection(SimpleDataSource.java:580)
at com.ibatis.common.jdbc.SimpleDataSource.getConnection(SimpleDataSource.java:222)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.init(JdbcTransaction.java:48)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:89)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:82)
at [].admRole.getCount(admRole.java:44)
at jeus_jspwork._jsp._500_managerAdmin_5fjsp._jspService(_500_managerAdmin_5fjsp.java:145)
at jeus.servlet.jsp2.runtime.HttpJspBase.service(HttpJspBase.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at jeus.servlet.jsp.JspServletWrapper.executeServlet(JspServletWrapper.java:147)
at jeus.servlet.servlets.JspServlet.execute(JspServlet.java:365)
at jeus.servlet.engine.HttpRequestProcessor.run(HttpRequestProcessor.java:284)
As I stated in the question, strings are stored and retrieved correctly if they are re-encoded as EUC-KR before being turned into ISO-8859-1 (to save, or vice versa to retrieve).
I modified the two following classes:
com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap
com.ibatis.sqlmap.engine.mapping.result.ResultMap
In both cases, I took the Object[] array (parameters and columnValues), casted to String, and applied the encoding transformations.
I am not using oracle for quite a while, but I have some confidence that this is reason of your "listener does not currently know of SID given" error: Can I force JDBC Driver use UTF-8 Charset to encode?
I am a Chinese developer so the character encoding problem is pretty much the same(we are mostly using GBK character set here). As far as I can remember, "but it saves VARCHAR2 type columns as ASCII7" means that your oracle instance is a non-unicode installation?
The force use of string.getBytes(charset) above JDBC layer is really really bad in terms of maintenance and data interpretability(the string data is displayed as a mess to DBA; DBA can not use SQL to perform any string comparison on this column, etc). So my advice is try to contact your DBA and get the database working with unicode first, since Oracle is very capable of handling unicode data.