preparedstatement

search for more blogs here

 

"NAMED PARAMETERS FOR PREPARED STATEMENT" posted by ~Ray
Posted on 2008-11-13 12:20:42

StringBuffer query = new StringBuffer("INSERT INTO users (userid first_name last_name street city country zip_code));query append("VALUES (:userid. :fname. :lname. :street. :city. :country)");NamedParameterStatement statement= new NamedParameterStatement(conn,query toString());statement setString("userid" userid);statement setString("fname" fname );statement setString("lname". ;name );statement setString("street" street );statement setString("city" city);statement setString("country" country);statement executeUpdate(); Now if you want to insert a new parameter 'middle_initial' at third position it can be done as in the following. StringBuffer query = new StringBuffer("INSERT INTO users (userid first_name,middle_initial last_name street city,country zip_code));query append("VALUES (:userid. :fname. :middleinitial. :lname. :street. :city. :country)");NamedParameterStatement statement= new NamedParameterStatement(conn,query toString());statement setString("userid" userID);statement setString("fname" firstName);statement setString("lname" lastName);statement setString("street" street );statement setString("city" city);statement setString("country" country);statement setString("middleinitial" middleInitial);statement executeUpdate();

Forex Groups - Tips on Trading

Related article:
http://suryajava.blogspot.com/2007/10/named-parameters-for-prepared-statement.html

comments | Add comment | Report as Spam


"Blob and Clob Objects:JAVA" posted by ~Ray
Posted on 2008-01-01 21:16:42

Retrieving change surface and CLOB ValuesThe binary large object (BLOB) and character large disapprove (CLOB) data types aretreated similarly to the more primitive built-in types. Values of these types can beretrieved by calling the getBlob and getClob methods in the ResultSet andCallableStatement interfaces. For example. CODE EXAMPLE 16-1 retrieves a BLOBvalue from the first column of the ResultSet rsand a CLOB value from the secondcolumn. Blob change surface = rs getBlob(1);Clob clob = rs getClob(2);label EXAMPLE Retrieving BLOB and CLOB valuesThe Blob interface contains operations for returning the length of the BLOB value aspecific be of bytes contained in the BLOB value and so on. The Clob interfacecontains corresponding operations that are engrave based. The API documentationgives more details. An application does not deal directly with the LOCATOR(blob) andLOCATOR(clob) types that are defined in SQL. By default a JDBC driver shouldimplement the Blob and Clob interfaces using the appropriate locator type. Also bydefault. Blob and Clob objects remain valid only during the transaction in whichthey are created. Storing Blob and Clob ObjectsA Blob or Clob disapprove can be passed as an input parameter to aPreparedStatement object just desire other data types. The method setBlob sets aPreparedStatement parameter with a change surface disapprove and the method setClob setsa Clob disapprove as a parameter. In label EXAMPLE authorImageis an instance ofjava sql. Blob retrieved from another SQL statement and authorBio is a aninstance of java sql. Clob retrieved from another SQL statement. PreparedStatement pstmt = conn prepareStatement(“INSERT INTO bio (image text) VALUES (?. ?)");pstmt setBlob(1 authorImage);pstmt setClob(2 authorBio);CODE EXAMPLE Setting Blob and Clob objects as parameters to aPreparedStatement objectThe setBinaryStream and setObject methods may also be used to set a Blobobject as a parameter in a PreparedStatement object. The setAsciiStream,setCharacterStream and setObject methods are alternate means of setting aClob object as a parameter. The updateBlob and updateClob methods can be used to update a column valuein an updatable prove set. The Blob and Clob interfaces give methods to alter their internal circumscribe. InCODE EXAMPLE 16-3 the method setBytes is used to write the first five bytes of theBlob object retrieved from the column DATA byte[] val = {0,1,2,3,4};... Blob data = rs getBlob(“DATA”);int numWritten = data setBytes(1 val);label EXAMPLE Writing bytes to a.

Forex Groups - Tips on Trading

Related article:
http://computerpreferedcourses.blogspot.com/2007/11/blob-and-clob-objectsjava.html

comments | Add comment | Report as Spam


"Announcements :: RE: Servoy 3.5.2" posted by ~Ray
Posted on 2007-12-15 15:05:26

We announce the immediate availability of Servoy 3.5.2Make a backup of your current Servoy installation (directory and database) before installing. This version will be available shortly through auto modify for users of versions later than 3.5 b2 (analyse via help menu -> analyse for new version)Changes[new] new documentation[new] text orientation can be specified in solution settings[enh] workaround to enable Servoy cause to be perceived Client to work with an upcoming popular operating system[enh] possibility to override error and page expired web client page see below[enh] optional parameter "language" to the application showI18NDialog(...)[enh] web client support for navigator styles see below[enh] added child nodes sorting give to DBTreeView bean see below[enh] choose command will also be called for labels in table believe components without a data provider[fix] Servoy windows (cause to be perceived client/help/editor) are now able to remember their measure location and express (maximized or not) correctly change surface when using multiple monitors/displays[fix] standard servoy modal dialogs (not servoy user dialogs) will always be on top of their parent window[fix] dialog bounds are saved in properties register only if they are needed[fix] when creating a new global method while being on a module create the global ordain be created in the module instead of in the main solution[fix] create preview from web client did not work in Safari at least Safari for Windows[fix] in the onLoad method for instanced forms application getMethodTriggerFormlabel() did not work correctly (gave back the label of the initial form not the instanced one)[fix] printing a compose from developer[fix] in Sybase 10 the arrange_rtruncation option has a deafult determine of ON whereas =< Sybase 9 had it set to OFF by fail. This setting indicates to generate an exception when using the direct command and a certain situation occurs. In Sybase 9 and before the exception would be ignored by default in Sybase 10 it's raised. Due to this. Sample Data imports can fail in Sybase 10[fix] exception when the primary key is a stored calculation[fix] checkbox field not properly initialized when database value is null[fix] forbid call back when expanding/collapsing DBTreeView[fix] multi developer deadlock fix[fix] web client shows disabled tabs incorrectly[fix] editing of large tableviews: selection had strange behavior[fix] when calling readonly(...) while in edit mode listview would be in alter mode[fix] image media field in tableview did not fire the onAction method[fix] give to move files over multiple filesystems with file plugin[fix] security getUserName(...) will only go the current user name if no arguments are given; null argument will return null[fix] exception when executing calculation that fails[fix] error in creating repository on mysql5 database switching to mediumtext when column is longer than 255 (same behaviour as mysql4) to prevent "row size too big" error[fix] loading a foundset with a dataset of PKs could prove in a conversion write error[fix] unrelate(...) on related foundsets kept the sql connect[fix] error in printing when subsummary has more than three GroupByFields[fix] threading problem in plan plugin when used from group processorChanges in servoy_consume_crm[enh] Removed the dialog tabpanel "workaround" - and changed all dialogs to native Servoy modal dialogs - so everything is web compatible.[enh] Invoices with a CLOSED status are now not editable - and you are alerted when you click the "alter" add[enh] When you attach an CLOSED status invoice as OPEN you can alter all the items[enh] Added invoice status to the enumerate of invoices displayed on the product[chg] Removed the global functions that disabled the check prior to the "fake" dialog calls - as they are no longer necessary with "real" dialogs[chg] Upated the "alter" routines on all the main forms - so that checkboxes are editable in the Web Client[fix] Updated the svy_mod solution to shift extra global methods that were no longer being referenced[fix] Updated the global methods that opened the dialogs - there were too many arguments being passed and in the do by request - causing strange results[fix] Modified the svyWebCrm call to consider "color" background fields - for checkboxes so they wouldn't be colored color after editing on contacts and invoices.[fix] Changed sort of existing orders on products create to choose by order id[fix] Set the navigation bar tabpanel to transparent on all the forms - to avoid the occassional color bar on redraw of screen[fix] Changed the go out and be formatting on orders contacts companies to be US format - and not show the time on date fieldsDBTreeView bean child nodes sorting supportThe DBTreeView hit now allows sorting the child nodes through the bindNodeChildSortDataProvider(sort_column_provider) function. Use this function to set the label of a calculation. The calculation should return a string of the create <column label> <sort order>. The children ordain be sorted on the column and in the order returned by this calculation. Overriding error- and page expired pagesBy using application setUserProperty(...) the error page and page expired pages can now be set on a per-user basis. These properties are servoy webclient error page and servoy webclient pageexpired page respectively. These override the properties by the same name from the admin page. The defaults must be set in the admin summon for the user properties to bring home the bacon. Style support for navigatorThe fail navigator can now be styled using the classes navigatornumber navigatornext navigatorprev navigatorfirst and navigatorlast. Example: How do I upgrade a solution from Servoy 3.1.7-build 411 to Servoy 3.5.2?I would like to stay with Sybase 9 initially to minimize the variables in case something should go wrong. From the instructions it appears that the only way to stay with Sybase 9 is to perform incremental Servoy updates. However from Servoy 3.1.7-build 411 it appears that there are no more incremental updates available. How do I make the leap from where I am to where I need to be?Dean The DBTreeView bean now allows sorting the child nodes through the bindNodeChildSortDataProvider(choose_column_provider) function. Use this function to set the label of a calculation. The calculation should return a string of the create <column label> <choose request>. The children will be sorted on the column and in the request returned by this calculation. Are you sure this works in 3.5.2? It still reacts as in 3.5.1 change surface when I added the bindNodeChildSortDataProvider('column_order asc') method. Or is there some particular moment when this method has to be set? For example before or after the loadrecords into the treeview?_________________MartinGlobis N. V. Aalst - Belgium------------------------------------------------Servoy Developer Version 3.5.3-build 516Java version 1.6.0_03-b05 (Windows XP)Database SQL Server 2005 2007-10-29 21:23:57,602 ERROR [TaskExecuter[1]] com servoy j2db util. Debug - Throwablecom servoy j2db persistence. RepositoryException: com servoy j2db persistence. RepositoryException: com mysql jdbc. MysqlDataTruncation: Data truncation: Data too long for column 'media_data' at row 1at com servoy j2db persistence p a(Unknown Source)at com servoy j2db persistence. XMLImporter importFromJarFile(Unknown Source)at com servoy j2db create i$6 run(Unknown Source)at com servoy j2db util aq run(Unknown obtain)at java lang. Thread run(Unknown Source)Caused by: com servoy.

Forex Groups - Tips on Trading

Related article:
http://forum.servoy.com/viewtopic.php?p=47051#47051

comments | Add comment | Report as Spam


"DB Interview questions Part3" posted by ~Ray
Posted on 2007-12-09 13:38:47

5. Is the JDBC-ODBC connect multi-threaded? - No. The JDBC-ODBC connect does not give concurrent find from different threads. The JDBC-ODBC connect uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge but they won’t get the advantages of multi-threading. 6. Does the JDBC-ODBC Bridge give multiple concurrent open statements per connection? - No. You can open only one Statement object per connection when you are using the JDBC-ODBC connect. 7. What is cold backup hot backup warm backup recovery? - Cold backup (All these files must be backed up at the same time before the databaseis restarted). Hot backup (official label is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users. 8. When we ordain Denormalize data? - Data denormalization is reverse procedure carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data. 9. What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time ordain be less. The PreparedStatement disapprove contains not just an SQL statement but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to hive away it first. 10. What is a “dirty read”? - Quite often in database processing we come across the situation wherein one transaction can change a value and a back up transaction can read this value before the original change has been committed or rolled back. This is known as a dirty construe scenario because there is always the possibility that the first transaction may rollback the change resulting in the second transaction having construe an invalid determine. While you can easily dominate a database to disallow dirty reads this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency. 11. What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java sql. DatabaseMetaData) or Information about a specific ResultSet (java sql. ResultSetMetaData). Use DatabaseMetaData to find information about your database such as its capabilities and coordinate. Use ResultSetMetaData to find information about the results of an SQL ask such as size and types of columns 12. Different types of Transaction Isolation Levels? - The isolation aim describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to construe the same row of a table. Imagine two transactions: A and B. Here three types of inconsistencies can occur: o Dirty-read: A has changed a row but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls back his changes and updates his own changes to the database o Non-repeatable read: B performs a read but A modifies or deletes that data later. If B reads the same row again he will get different data o Phantoms: A does a ask on a set of rows to act an operation. B modifies the table such that a query of A would undergo given a different prove. The table may be inconsistent. TRANSACTION_READ_UNCOMMITTED : alter READS. NON-REPEATABLE construe AND PHANTOMS CAN become. TRANSACTION_construe_COMMITTED : alter READS ARE PREVENTED. NON-REPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_REPEATABLE_construe : alter READS. NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR. TRANSACTION_SERIALIZABLE : DIRTY READS. NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.

Forex Groups - Tips on Trading

Related article:
http://interview-questions-and-answers.blogspot.com/2007/10/db-interview-questions-part3.html

comments | Add comment | Report as Spam


"DB Interview questions Part3" posted by ~Ray
Posted on 2007-12-09 13:38:47

5. Is the JDBC-ODBC connect multi-threaded? - No. The JDBC-ODBC connect does not give concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the connect but they won’t get the advantages of multi-threading. 6. Does the JDBC-ODBC Bridge give multiple concurrent change state statements per connection? - No. You can change state only one Statement object per connection when you are using the JDBC-ODBC Bridge. 7. What is cold backup hot backup warm backup recovery? - Cold backup (All these files must be backed up at the same time before the databaseis restarted). Hot backup (official name is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users. 8. When we will Denormalize data? - Data denormalization is reverse procedure carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to bend data for certain data. 9. What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement disapprove contains not just an SQL statement but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to compile it first. 10. What is a “dirty read”? - Quite often in database processing we come across the situation wherein one transaction can change a value and a second transaction can read this value before the original dress has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change resulting in the second transaction having construe an invalid determine. While you can easily dominate a database to disallow alter reads this usually degrades the performance of your application due to the increased locking overhead. Disallowing alter reads also leads to decreased system concurrency. 11. What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java sql. DatabaseMetaData) or Information about a specific ResultSet (java sql. ResultSetMetaData). Use DatabaseMetaData to sight information about your database such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL ask such as size and types of columns 12. Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to construe the same row of a table. create by mental act two transactions: A and B. Here three types of inconsistencies can occur: o Dirty-read: A has changed a row but has not committed the changes. B reads the uncommitted data but his believe of the data may be wrong if A rolls approve his changes and updates his own changes to the database o Non-repeatable read: B performs a construe but A modifies or deletes that data later. If B reads the same row again he will get different data o Phantoms: A does a ask on a set of rows to act an operation. B modifies the table such that a ask of A would have given a different result. The table may be inconsistent. TRANSACTION_READ_UNCOMMITTED : alter READS. NON-REPEATABLE READ AND PHANTOMS CAN become. TRANSACTION_READ_COMMITTED : alter READS ARE PREVENTED. NON-REPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_REPEATABLE_construe : DIRTY READS. NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR. TRANSACTION_SERIALIZABLE : alter READS. NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.

Forex Groups - Tips on Trading

Related article:
http://interview-questions-and-answers.blogspot.com/2007/10/db-interview-questions-part3.html

comments | Add comment | Report as Spam


"DB Interview questions Part3" posted by ~Ray
Posted on 2007-12-09 13:38:46

5. Is the JDBC-ODBC connect multi-threaded? - No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC connect uses synchronized methods to arrange all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge but they won’t get the advantages of multi-threading. 6. Does the JDBC-ODBC connect support multiple concurrent open statements per connection? - No. You can open only one Statement disapprove per connection when you are using the JDBC-ODBC Bridge. 7. What is cold backup hot backup change backup recovery? - Cold backup (All these files must be backed up at the same measure before the databaseis restarted). Hot backup (official label is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users. 8. When we ordain Denormalize data? - Data denormalization is reverse procedure carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to bend data for certain data. 9. What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement disapprove contains not just an SQL statement but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to hive away it first. 10. What is a “alter read”? - Quite often in database processing we come across the situation wherein one transaction can dress a determine and a back up transaction can construe this value before the original change has been committed or rolled back. This is known as a dirty construe scenario because there is always the possibility that the first transaction may rollback the change resulting in the second transaction having construe an invalid value. While you can easily command a database to command dirty reads this usually degrades the performance of your application due to the increased locking overhead. Disallowing alter reads also leads to decreased system concurrency. 11. What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java sql. DatabaseMetaData) or Information about a specific ResultSet (java sql. ResultSetMetaData). Use DatabaseMetaData to sight information about your database such as its capabilities and structure. Use ResultSetMetaData to sight information about the results of an SQL query such as size and types of columns 12. Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to read the same row of a delay. create by mental act two transactions: A and B. Here three types of inconsistencies can occur: o Dirty-read: A has changed a row but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls approve his changes and updates his own changes to the database o Non-repeatable construe: B performs a read but A modifies or deletes that data later. If B reads the same row again he will get different data o Phantoms: A does a query on a set of rows to perform an operation. B modifies the table such that a query of A would have given a different result. The table may be inconsistent. TRANSACTION_READ_UNCOMMITTED : DIRTY READS. NON-REPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_construe_COMMITTED : alter READS ARE PREVENTED. NON-REPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_REPEATABLE_construe : alter READS. NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN become. TRANSACTION_SERIALIZABLE : DIRTY READS. NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.

Forex Groups - Tips on Trading

Related article:
http://interview-questions-and-answers.blogspot.com/2007/10/db-interview-questions-part3.html

comments | Add comment | Report as Spam


"preparedStatement ???" posted by ~Ray
Posted on 2007-11-27 20:03:15

arrange label = request getParameter("label");preparedStatement pstmt=conn prepareStatement(sql);pstmt setString(1,label);// 1번째? 에다 label이라는 파라미터값을 넣어주겠다라는 뜻. ResultSet rs= pstmt,excuteQuery(); pstmt setString(1,"홍길동"); //재사용도 할수있다 rs=pstmt executQuery(); //재사용자료 펌) ================================= 1. 사용자 입력값으로 쿼리를 생성하는 경우 사용자에의해 입력되는 값을 가지고 SQL 작업을 할 경우 statement를 사용한다면 다음과 같이 될 것이다. arrange content = request getParameter("content"); stmt= channelise createStatement(); stmt executeUpdate("INSERT INTO TEST_TABLE (circumscribe) VALUES('"+circumscribe+"'); 사용자가 제대로 입력 하였다면 상관 없지만 circumscribe값에 "AA'AA"를 입력하였다면? stmt executeUpdate("INSERT INTO TEST_TABLE (CONTENT) VALUES('"+circumscribe+"'); 에서 즉 SQL문은 다음과 같이 되는 것이다. INSERT INTO evaluate_TABLE (CONTENT) VALUES('AA'AA'); 요렇게 에러가 나면 그나마 다행.. 만약 이쿼리가 대용량 쿼리 문장이었다면.. SELECT * FROM evaluate_TABLE WHERE circumscribe = :circumscribe 그리고 사용자가 고의적으로 circumscribe값을 "' AND content like '%1%" 같이 입력하였다면 큰일이다. 즉 evaluate_TABLE을 풀스캔 하여 엄청난 로드가 걸릴 수 있다는 것이다. 이와같이 사용자가 컬럼명을 유추하여 얼마든지 쿼리를 만들 수 있으며 비정상적 물론 사용자 입력값을 체크하여 적당한 값으로 치환해주는 작업을 해도 무방하지만 귀찮은 일이다. 이를 다음과 같이 수정한다면 위와같은 에러나 장애를 원천적으로 봉쇄할 수 있다 pstmt = channelise preapreStatement("SELECT * FROM evaluate_delay WHERE CONTENT = :circumscribe"); pstmt setString(1 content); pstmt executeUpdate(); 이는 circumscribe값이 "'"가 들어왔다 하더라도 알아서 파싱 해주기 때문이다. 고로 사용자 입력 값으로 쿼리를 바인딩 할 경우에는 필히 pstmt를 사용하도록 하자! :) 일반적으로 반복 수행 작업을 할 경우 아래와 같이 코딩 하게 된다. 1) Statement 사용 for (int i = 0; i < 100000; i++) { stmt executeUpdate("attach INTO TEST_TABLE VALUES('"+circumscribe+"'); } 2) PreparedStatement 사용 pstmt = conn preapreStatement("INSERT INTO evaluate_TABLE VALUES(?)"); <--- ⓐ for (int i = 0; i < 10000; i++) { pstmt setString(1 content+i); pstmt executeUpdate(); } 종종 실수로 ⓐ번 문장이 for문으로 들어가는것을 보게된다! 주의! -. DB의 종류에 따라 상황이 달라진다. 일반적으로 위와같은 코딩을 할 경우 2)경우가 1)보다 더 낳은 성능을 보인다고 알려져 있다. 즉 자바의 PreparedStatement의 사용은 오라클 DB에서 bind변수를 사용하도록 함으로 해서 DB서버에 미리 준비된 SQL을 사용하게 되고 파싱과정을 생략하기 때문에 결국 DB리소스를 효율적으로 사용하도록 하는 방법이 된다. 하지만 이것이 DB서버에 따라 다르다. MySql같은 경우는 1)과2)의 성능차이가 거의 나지 않는다. -. 적당한 PreparedStatement의 사용 위와같은 이유로 PreparedStatement가 좋다! 모든 쿼리를 PreparedStatement로 하자! 만약 이와 같이 된다면 또다른 문제가 생긴다. 각 DB마다 SQL캐싱할 수 있는 한계가 있기 때문에 정작 성능상 캐싱되어야 할 쿼리가 그렇지 않은 쿼리 때문에 캐싱이 안 될 수 있기때문에 꼭 필요한 문장만 Dynamic SQL을 사용한다면 매번 조건절이 틀려지게 됨으로 statement가 낳겠지요 즉 캐싱의 장점을 잃어버립니다. 또한 Dynamic SQL일 경우 코딩도 Statement가 훨신 편하니다. PreparedStatement보다 Statement가 디버깅이 훨씬 편한것은 사실입니다. preparedstatement를 디버깅 하려면 따로 래퍼 클래스를 만들거나 jakarta commons의 dbutil을 사용하면 어느정도 디버깅은 할 수 있습니다. 필자가 생각하는 최상의 방법은.. 일단 SQL자체가 최상의 효과를 내는 쿼리 이어야 하며. 위에서 언급한 몇가지 사항을 최대한 고려해서 조건문이 수시로 변하는 쿼리는 Statement 로. 조건문이 변하지 않는 것은 PreparedStatement로 작성하면 캐싱의 효과를 최대로 활용할 수 있으리라 생각됩니다. ^^ ============================우선 속도면에서 PreparedStatement 가 빠르다고 알려져 있습니다.이유는 쿼리를 수행하기 전에 이미 쿼리가 컴파일 되어져 있으며,반복 수행하게 된다며 그 프리컴파일된 쿼리를 바로 수행하기 때문이라고 합니다.또한. 일반 쿼리를 수행한다면 처리해야하는 잡다한 문제들을 피할 수 있습니다.예를 들어. 싱클 코테이션(') 이 들어갈 경우 varchar 같은 데이타 타입은따로 처리를 해주어야 한다든지 하는 것들을 신경쓸 필요도 없습니다.그리고. 쿼리가 길어지면. 일반 쿼리문은 대개 지저분해지기 마련 인데,이럴때 또한 장점인것 같습니다.실제로 적용하시다 보면 다른 장점을 찾을 수도 있을 것입니다.어떤 때는 그냥 Statement가 더 나을때도 있을 것이며 선택은 님에게 달려있습니다.===================================== 책에 이런 말이 있는데..테스트는 못해봤습니다 setString을 써서 아래와 같은 에러 메세지는 많이 봤습니다. 해보진 않았지만 맞는 말 같습니다. 지금쯤 버그가 해결돼었을지 모르지만.. /* PreparedStatement를 이용하여 데이터베이스에 문자열을 입력하기 위하여 setString()메소드를 사용하여 한 행을 insert시킬 때 컬럼 타입이 varchar2(4000)로 정의되어 있어도 영문은 2000자. 한글은 600자 정도밖에 입력이 되질 않는다. 만약 이 범위를 벗어나는 데이터를 입력했을 시 나타나는 에러 메시지는 "데이타 크기가 해당 유형의 최대 크기보다 큽니다."라는 에러 메시지를 보여준다. 에러가 발생하는 이유는 PreparedStatement의 setString()메소드의 버그이므로 setString()메소드를 사용하면 안된다 setString()메소드 대신 setCharacterStream()메소드를 이용하여 입력하여야 한다. arrange call=""; arrange ask="attach into table1 values(?)"; PreparedStatement pstmt=con prepareStatement(query); pstmt setCharacterStream(1,new StringReader(title),call length()); pstmt executeUpdate();*/

Forex Groups - Tips on Trading

Related article:
http://4rang.tistory.com/320

comments | Add comment | Report as Spam


"Problems with Spoon - Cpying Tables" posted by ~Ray
Posted on 2007-11-17 15:34:53

This is a TEST SITE ONLY. All data outside of the Migration give Forum ordain be deleted the day before the live forum migration. So feel remove to affix edit posts set up profile information etc. with the understanding that those changes will not be preserved! Hello everyone... I am having a problem with basic transformations. I am trying to copy a table from schema1 delay1 to schema2 table1 in MySQL and Spoon in running into errors. I have even tried using the "copy table" wizard with no luck. I undergo however been successfull in transforminto tables to textfile output (for back Up purposes). I am using Windows Vista Basic. JAVA_domiciliate is pointing to C:\Program Files\Java\jdk1.5.0_13 The error message displayed in the transformation is: 2007/11/05 13:37:54 - Spoon - Transformation opened.2007/11/05 13:37:54 - Spoon - Launching transformation [Copy delay from [mysql_capta_fact] to [mysql_captaciones]]...2007/11/05 13:37:54 - Spoon - Started the transformation execution.2007/11/05 13:37:54 - Copy delay from [mysql_capta_fact] to [mysql_captaciones] - Dispatching started for transformation [write table from [mysql_capta_fact] to [mysql_captaciones]]2007/11/05 13:37:54 - Copy table from [mysql_capta_fact] to [mysql_captaciones] - Nr of arguments detected:10 2007/11/05 13:37:54 - write table from [mysql_capta_fact] to [mysql_captaciones] - This is not a reproduce transformation2007/11/05 13:37:54 - Copy delay from [mysql_capta_fact] to [mysql_captaciones] - This transformation can be replayed with replay date: 2007/11/05 13:37:542007/11/05 13:37:54 - Copy table from [mysql_capta_fact] to [mysql_captaciones] - Initialising 3 steps...2007/11/05 13:37:54 - create verbally to [capta_fact].0 - Connected to database [mysql_captaciones] (commit=200)2007/11/05 13:37:54 - read from [capta_fact].0 - Starting to run...2007/11/05 13:37:54 - write to [capta_fact].0 - Starting to run...2007/11/05 13:37:54 - create verbally to [capta_fact] Mapping.0 - Starting to run...2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : java sql. SQLException: Incorrect arguments to mysql_stmt_execute2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at com mysql jdbc. MysqlIO checkErrorPacket(MysqlIO ja va:2975)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at com mysql jdbc. MysqlIO sendCommand(MysqlIO java:16 00)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at com mysql jdbc. ServerPreparedStatement serverExecu te(ServerPreparedStatement java:1129)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : at com mysql jdbc. ServerPreparedStatement executeInte rnal(ServerPreparedStatement java:681)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at com mysql jdbc. PreparedStatement executeUpdate(Pre paredStatement java:1368)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at com mysql jdbc. PreparedStatement executeUpdate(Pre paredStatement java:1283)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : at com mysql jdbc. PreparedStatement executeUpdate(Pre paredStatement java:1268)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : at be ibridge kettle core database. Database insertRow (Database java:1774)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : at be ibridge kettle trans go tableoutput. TableOutp ut writeToTable(TableOutput java:178)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : at be ibridge kettle trans go tableoutput. TableOutp ut processRow(TableOutput java:72)2007/11/05 13:37:54 - mysql_captaciones - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : at be ibridge kettle trans go tableoutput. TableOutp ut run(TableOutput java:334)2007/11/05 13:37:54 - write to [capta_fact].0 - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : Because of an error this step can't continue: 2007/11/05 13:37:54 - write to [capta_fact].0 - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : Error inserting row into table [captaciones capta_fact] with values: [PLAZ= 101. TPER=6.75000000000000000. VIUF=2000.00000000000000000. IPER=37.88000000000000000. NOM_REGION2=SIERRA. NOMCOR_OFICINA=Sto Domingo. NOM_PROV=Pichincha. NOM_CIUDAD=Santo Domingo. DESCRIPCION=CDP-Al Vencimiento. YEAR= 2007. TRIMESTR=Trim1. MES_NUM= 1. MES_NOM=Ene. CLIENTE=MENDOZA LEON JORGE LIBORIO. NOM_OFICIAL=GALLEGOS ALAVA CRISTOBAL RAFAEL. RANGO=91 a 180d. RANGO_ORD= 3. MXP=202000.00000. MXI=135.00000]2007/11/05 13:37:54 - write to [capta_fact].0 - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : 2007/11/05 13:37:54 - write to [capta_fact].0 - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : Error inserting row2007/11/05 13:37:54 - create verbally to [capta_fact].0 - ERROR (version 2.4.0 build 742 from 2007/01/27 12:29:00) : Incorrect arguments to mysql_stmt_kill2007/11/05 13:37:54 - create verbally to [capta_fact].0 - Finished processing (I=0. O=0. R=1. W=0. U=0. E=12007/11/05 13:37:54 - write delay from [mysql_capta_fact] to [mysql_captaciones] - ERROR (version 2.4.0 create 742 from 2007/01/27 12:29:00) : Errors detected!2007/11/05 13:37:54 - Copy delay from [mysql_capta_fact] to [mysql_captaciones] - Looking at step: read from [capta_fact]2007/11/05 13:37:54 - read from [capta_fact].0 - Finished reading query closing connection.2007/11/05 13:38:00 - read from [capta_fact].0 - Finished processing (I=292. O=0. R=0. W=290. U=0. E=02007/11/05 13:38:00 - Copy table from [mysql_capta_fact] to [mysql_captaciones] - Looking at step: write to [capta_fact] Mapping2007/11/05 13:38:00 - create verbally to [capta_fact] Mapping.0 - Finished processing (I=0. O=0. R=290. W=290. U=0. E=02007/11/05 13:38:00 - Copy table from [mysql_capta_fact] to [mysql_captaciones] - Looking at go: create verbally to [capta_fact]2007/11/05 13:38:00 - Spoon - The transformation has finished!! I'd acknowledge any asistance you can give. Regards. DMurray3 Thank you Matt. I am trying to transfer the latest version of Kettle; in the meantime in order tyo modify the jdbc connector used in Kettle gratify confirm if the mysql connector jar file is located in../libext or../libswt folder and if replacing this file should work. Thanks again for your response.. Regards. DMurray3 It seems very likely that you are hit by a MySQL JDBC or Server bug. I would like to suggest to give a more recent version of the JDBC driver (or Kettle) a try. Matt

Forex Groups - Tips on Trading

Related article:
http://forums.pentaho.org/showthread.php?t=57781

comments | Add comment | Report as Spam


"PreparedStatement SetObject Invalid data conversion exception" posted by ~Ray
Posted on 2007-11-09 17:18:52

The problem is that the code above fails with SQLException:remove data conversion: Parameter disapprove write is invalid for requested conversion. I thought that the setObject will auto-map the object to the relevant data type (in this case java sql. Date)... SQLException Sets the determine of the designated parameter using the given disapprove. The back up parameter must be of type Object; therefore the java lang equivalent objects should be used No not in command. It depends on the JDBC driver used. The recent MySQL. PostgreSQL and DB2 JDBC drivers supports setting java util. go out through PreparedStatement#setObject() however. What DB and which driver are you using? I am using DB2 in the current example but I am writting generic code that can bring home the bacon in any db is there any way to check if there is a auto-mapping between the variable type provided and java sql. For instance. I undergo the following method which I would like not to go any java sql objects I undergo to ascertain myself the DB2 JDBC driver doesn't support java util. go out for that. At least the MySQL JDBC driver does it here. You can believe writing a generic object converter. If value instanceof java util. Date then convert it. Isn't Hibernate an option for you however? Learning turn may be a bit high but it would deliver you much effort regarding things desire that. I desire it was. I am writing a generic simple framework for data find for use in an introduction to java class. I was thinking about object converter but from what you mentioned it depends on the db. Mysql can alter go out to java sql. Date while DB2 cannot. Is there any way to know disapprove type T is successfully converted with the current driver (without going through the annoy of tracking the exception thrown by setObject). I would say roughly convert as much as possible non-java lang.* and non-java sql.* types to a java sql.* write. Then you're almost guaranteed that setObject() ordain bring home the bacon. It might cost measure writing code but then you've something useful. This may back up you advance here (especially 8.9.5): http://java sun com/j2se/1.5.0/docs/guide/jdbc/getstart/mapping html Hey guys. I have tried to map java objects to java sql objects as discussed above. But now I have a problem when the argument obj in setObject(i obj) is null. Is there a generic way to beat this problem?I am aware of setNull(row. TYPE) but I dont be to set the type explicitly cause this is not generic. e g setNull(1. Types. NULL) fails and I get anunknown type exception (something like that) You be to pass the actual SQL write of the column to alter it to SQL NULL. Example:

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5208631

comments | Add comment | Report as Spam


"PreparedStatement-question" posted by ~Ray
Posted on 2007-11-03 13:50:35

it don't work cause of the query is wrong ('tablename' instead of tablename). Which datatype is to choose for this ?I can't do a normal "String-query" like : create of a binary array which is part of the query. Thats why only a PreparedStatement works regardsOlek there is a setBinaryStream() method that comes with PreparedStatement try using it for your binary arrange. hi,The byte-array is no problem. The problem is the table-name arrange. PreparedStatement setString() convert a String to 'arrange' so it is ok if the arrange is part of the WHERE ask. But the label of the delay must be only the string not with the ' '. So how to act a PreparedStatement likeSelect table row from ? where ? = ?. The problem is again the ? which present the delay. Olek ;PreparedStatement ps = Connection prepareStatement(fetchRow);ps setBytes(1 binaryArray); Unless otherwise licensed label in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5214116

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the preparedstatement archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


preparedstatement