Source Code Cross Referenced for lobLengthTests.java in  » Database-DBMS » db-derby-10.2 » org » apache » derbyTesting » functionTests » tests » largedata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derbyTesting.functionTests.tests.largedata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derbyTesting.functionTests.tests.largedata.lobLengthTests
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to You under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derbyTesting.functionTests.tests.largedata;
023:
024:        import java.sql.Connection;
025:        import java.sql.PreparedStatement;
026:        import java.sql.Statement;
027:        import java.sql.SQLException;
028:
029:        import java.io.ByteArrayInputStream;
030:
031:        import org.apache.derby.tools.ij;
032:        import org.apache.derby.tools.JDBCDisplayUtil;
033:
034:        /**
035:         * This test is part of the "largedata" suite because the use of
036:         * very large LOBs can require extra memory for the server JVM.
037:         * If this test was run as part of the normal 'derbyall' suite,
038:         * it would require that any developer running the derbyall suite
039:         * have a machine with a good deal of memory.  And since _every_
040:         * developer is encouraged to run 'derbyall' before submitting
041:         * any patches, that would mean that _every_ developer would
042:         * need a machine with lots of memory--and that's something we
043:         * do NOT want to require.
044:         * 
045:         * The specific JVM memory requirements for this test are set in the
046:         * properties file for this test (lobLengthTests_app.properties).
047:         * It started out as -mx128M -ms128M, but that could change in the
048:         * future as more test cases are added to this class.  If it's not
049:         * at least 128M, the result will be OutOfMemory exceptions when
050:         * running against Network Server.
051:         */
052:
053:        public class lobLengthTests {
054:
055:            /**
056:             * Create an instance of this class and do the test.
057:             */
058:            public static void main(String[] args) {
059:                new lobLengthTests().go(args);
060:            }
061:
062:            /**
063:             * Create a JDBC connection using the arguments passed
064:             * in from the harness, and then run the LOB length
065:             * tests.
066:             * @param args Arguments from the harness.
067:             */
068:            public void go(String[] args) {
069:                try {
070:
071:                    // use the ij utility to read the property file and
072:                    // make the initial connection.
073:                    ij.getPropertyArg(args);
074:                    Connection conn = ij.startJBMS();
075:
076:                    // Add additional tests here.
077:                    derby_121Test(conn);
078:
079:                } catch (Exception e) {
080:
081:                    System.out.println("FAIL -- Unexpected exception:");
082:                    e.printStackTrace(System.out);
083:
084:                }
085:            }
086:
087:            /**
088:             * There was a defect (DERBY-121) where the server and client
089:             * were processing lob lengths incorrectly.  For lob lengths
090:             * that are represented by 24 or more bits, the server and
091:             * Derby client were doing incorrect bit-shifting.  This
092:             * test makes sure that problem no longer occurs.
093:             */
094:            private static void derby_121Test(Connection conn)
095:                    throws SQLException {
096:                System.out
097:                        .println("Testing server read of lob length > 2^24 bytes.");
098:
099:                boolean autoc = conn.getAutoCommit();
100:                conn.setAutoCommit(false);
101:
102:                // Create a test table.
103:                Statement st = conn.createStatement();
104:                st.execute("create table lobTable100M(bl blob(100M))");
105:
106:                PreparedStatement pSt = conn
107:                        .prepareStatement("insert into lobTable100M(bl) values (?)");
108:
109:                // The error we're testing occurs when the server
110:                // is shifting bits 24 and higher of the lob's
111:                // length (in bytes).  This means that, in order
112:                // to check for the error, we have to specify a
113:                // lob length (in bytes) that requires at least
114:                // 24 bits to represent.  Thus for a blob the
115:                // length of the test data must be specified as
116:                // at least 2^24 bytes (hence the '16800000' in
117:                // the next line).
118:                byte[] bA = new byte[16800000];
119:                pSt.setBinaryStream(1, new java.io.ByteArrayInputStream(bA),
120:                        bA.length);
121:
122:                // Now try the insert; this is where the server processes
123:                // the lob length.
124:                try {
125:                    pSt.execute();
126:                    System.out.println("PASS.");
127:                } catch (Exception e) {
128:                    System.out.println("FAIL -- unexpected exception:");
129:                    e.printStackTrace(System.out);
130:                }
131:
132:                // Clean up.
133:                try {
134:                    st.execute("drop table lobTable100M");
135:                } catch (SQLException se) {
136:                }
137:
138:                conn.setAutoCommit(autoc);
139:                return;
140:
141:            }
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.