Source Code Cross Referenced for JDBC4ServerPreparedStatement.java in  » Open-Source-JDBC-Driver » mysql » com » mysql » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. JDK Core
2. JDK Modules
3. JDK Modules com.sun
4. JDK Modules com.sun.java
5. JDK Modules Platform
6. JDK Modules sun
7. Open Source Build
8. Open Source Graphic Library
9. Open Source IDE Eclipse
10. Open Source J2EE
11. Open Source JDBC Driver
12. Open Source Library
13. Open Source Library Database
14. Open Source Net
15. Open Source Script
16. Science
17. Security
18. Sevlet Container
19. SUN GlassFish
20. Swing Library
21. Web Services apache cxf 2.0.1
22. Web Services AXIS2
23. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java Source Code / Java Documentation » Open Source JDBC Driver » mysql » com.mysql.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         Copyright (C) 2002-2007 MySQL AB
003:
004:         This program is free software; you can redistribute it and/or modify
005:         it under the terms of version 2 of the GNU General Public License as 
006:         published by the Free Software Foundation.
007:
008:         There are special exceptions to the terms and conditions of the GPL 
009:         as it is applied to this software. View the full text of the 
010:         exception in file EXCEPTIONS-CONNECTOR-J in the directory of this 
011:         software distribution.
012:
013:         This program is distributed in the hope that it will be useful,
014:         but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         GNU General Public License for more details.
017:
018:         You should have received a copy of the GNU General Public License
019:         along with this program; if not, write to the Free Software
020:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
021:
022:         */
023:
024:        package com.mysql.jdbc;
025:
026:        import java.io.Reader;
027:        import java.sql.NClob;
028:        import java.sql.SQLXML;
029:        import java.sql.SQLException;
030:
031:        import com.mysql.jdbc.Connection;
032:        import com.mysql.jdbc.MysqlDefs;
033:        import com.mysql.jdbc.SQLError;
034:        import com.mysql.jdbc.ServerPreparedStatement;
035:        import com.mysql.jdbc.ServerPreparedStatement.BindValue;
036:
037:        public class JDBC4ServerPreparedStatement extends
038:                ServerPreparedStatement {
039:
040:            public JDBC4ServerPreparedStatement(ConnectionImpl conn,
041:                    String sql, String catalog, int resultSetType,
042:                    int resultSetConcurrency) throws SQLException {
043:                super (conn, sql, catalog, resultSetType, resultSetConcurrency);
044:                // TODO Auto-generated constructor stub
045:            }
046:
047:            /**
048:             * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader,
049:             *      long)
050:             */
051:            public void setNCharacterStream(int parameterIndex, Reader reader,
052:                    long length) throws SQLException {
053:                // can't take if characterEncoding isn't utf8
054:                if (!this .charEncoding.equalsIgnoreCase("UTF-8")
055:                        && !this .charEncoding.equalsIgnoreCase("utf8")) {
056:                    throw SQLError
057:                            .createSQLException("Can not call setNCharacterStream() when connection character set isn't UTF-8");
058:                }
059:
060:                checkClosed();
061:
062:                if (reader == null) {
063:                    setNull(parameterIndex, java.sql.Types.BINARY);
064:                } else {
065:                    BindValue binding = getBinding(parameterIndex, true);
066:                    setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
067:
068:                    binding.value = reader;
069:                    binding.isNull = false;
070:                    binding.isLongData = true;
071:
072:                    if (this .connection.getUseStreamLengthsInPrepStmts()) {
073:                        binding.bindLength = length;
074:                    } else {
075:                        binding.bindLength = -1;
076:                    }
077:                }
078:            }
079:
080:            /**
081:             * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)
082:             */
083:            public void setNClob(int parameterIndex, NClob x)
084:                    throws SQLException {
085:                setNClob(parameterIndex, x.getCharacterStream(),
086:                        this .connection.getUseStreamLengthsInPrepStmts() ? x
087:                                .length() : -1);
088:            }
089:
090:            /**
091:             * JDBC 4.0 Set a NCLOB parameter.
092:             * 
093:             * @param parameterIndex
094:             *            the first parameter is 1, the second is 2, ...
095:             * @param reader
096:             *            the java reader which contains the UNICODE data
097:             * @param length
098:             *            the number of characters in the stream
099:             * 
100:             * @throws SQLException
101:             *             if a database error occurs
102:             */
103:            public void setNClob(int parameterIndex, Reader reader, long length)
104:                    throws SQLException {
105:                // can't take if characterEncoding isn't utf8
106:                if (!this .charEncoding.equalsIgnoreCase("UTF-8")
107:                        && !this .charEncoding.equalsIgnoreCase("utf8")) {
108:                    throw SQLError
109:                            .createSQLException("Can not call setNClob() when connection character set isn't UTF-8");
110:                }
111:
112:                checkClosed();
113:
114:                if (reader == null) {
115:                    setNull(parameterIndex, java.sql.Types.NCLOB);
116:                } else {
117:                    BindValue binding = getBinding(parameterIndex, true);
118:                    setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
119:
120:                    binding.value = reader;
121:                    binding.isNull = false;
122:                    binding.isLongData = true;
123:
124:                    if (this .connection.getUseStreamLengthsInPrepStmts()) {
125:                        binding.bindLength = length;
126:                    } else {
127:                        binding.bindLength = -1;
128:                    }
129:                }
130:            }
131:
132:            /**
133:             * @see java.sql.PreparedStatement#setNString(int, java.lang.String)
134:             */
135:            public void setNString(int parameterIndex, String x)
136:                    throws SQLException {
137:                if (this .charEncoding.equalsIgnoreCase("UTF-8")
138:                        || this .charEncoding.equalsIgnoreCase("utf8")) {
139:                    setString(parameterIndex, x);
140:                } else {
141:                    throw SQLError
142:                            .createSQLException("Can not call setNString() when connection character set isn't UTF-8");
143:                }
144:            }
145:        }
ww___w.j_av_a__2_s___._co___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.