Amazon

Monday, June 8, 2009

XTream - Java-XML and XML-Java

To convert Java objects to XML and XML to Java Objects, XStream is very good utility library.
Following jars are required to use XStream APIs.

  1. xpp3-1.1.3.4d_b4_min.jar
  2. xstream-1.1.2.jar


Initialization of XStream will work for Java-XML and XML-Java conversion if same set of tags and java objects are going to be used for conversion.


Lets see very simple example. In the first part following example is about converting java objects to following xml document. And in the second part the we will convert the same xml document into Java objects.


Part one – Converting Java objects into following XML document structure. The XML document will contain <team-player-mapping> as root tag and n number if <team teamid=”12”> tags. The <team> tag will have n number of player tags.
<team-player-mapping>
<team id=413>
<player>ASIF</player>
<player>RAM</player>
<player>GOLDU</player>
<player>VIKY</player>
<player>AJAY</player>
<player>MANOJ</player>
</team>
<team id=410>
<player>AKRAM</player>
<player>MOHAN</player>
<player>KISHOR</player>
</team>
<team id=408>
<player>RIK</player>
<player>ASTER</player>
<player>FOSTER</player>
<player>FSCP</player>
</team>
</team-player-mapping>

By Seeing the xml document structure, the Java classes will be in same hierarchy/structure, in short, the child tags will be member variables in java classes (referring parent tags in xml).
For Example:
public class TeamPlayerMapping implements Serializable{
List team; //collection on Team class objects,
//collection of <team> in <team-player-mapping>
public List getTeam() {
return team;
}

public void setTeam(List team) {
this.team = team;
}
}


public class Team implements Serializable {
private String id; //attribute teamid in <team>,
//will also be treated as child
private List player; //Collection of Player, <player> in <team>

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public Team(){
}

public Team(String id){
setId(id);
}

public List getPlayer() {
return player;
}

public void setPlayer(List player) {
this.player = player;
}
}


public class Player{
String player;
public String getPlayer(){
return player;
}
public void setPlayer(String player){
this.player=player;
}
}


Initializing XStream object: In this part the proper hierarchy of classes is expressed to XStream object and aliasing the class name to proper xml tag or attribute name is expressed/set.

XStream xstream = new XStream();xstream.alias("team", Team.class); //"team" tag
xstream.alias(“team-player-mapping”, TeamPlayerMapping.class);

xstream.alias(“player”, String.class); //"player" tag

//Team List(collection) in TeamPlayerMapping - n number of Team tags in team-player-//mapping tag.

xstream.addImplicitCollection(TeamPlayerMapping.class, "team", Team.class);


//atribute of team tag - id is a String type member in Team class which will become attribute

//afer using following api.

xstream.useAttributeFor(Team.class, "id");


//player List(collection) in Team

xstream.addImplicitCollection(Team.class, “player”, String.class);

Setting the hierarchy of objects in XStream object. Here values are assigned in the objects in proper hierarchy and set into XStream to generate the xml format, shown above.


List teamL = new LinkedList();teamPlayerMapping.setTeam(teamL);
HashMap teamPlayer = loadPlayerMappings();
for(java.util.Iterator keys = teamPlayer.keySet().iterator(); keys.hasNext(); ){
String key = (String)(keys.next());//Team ID

//Add a new Team object in teamL collection.
Team team = new Team();
//Set collection of Player objects in Team object
List playerList = (List)teamPlayer.get(key);
team.setPlayer(playerList);
team.setId(key);
teamL.add(team);
}
return xstream.toXML(teamPlayerMapping).trim();

Following Returns a HashMap in a hierarchy like key as team id and value as list of players. This hashmap is converted into respective xml/xstream hierarchy in the code above.


public HashMap loadPlayerMappings() throws Exception{
HashMap teamPlayer = new LinkedHashMap();
try{
CachedRowSet cRset = this.getResultSet(SQL_SEL_ACCESS);
String tmpTeamID = "";
List playerList = new LinkedList();
while(cRset.next()){
String teamId = cRset.getString("TEAM_ID");
String playerId = cRset.getString("PLAYER_ID");
if(!tmpTeamID.equals(teamId)){
playerList = new LinkedList();
teamPlayer.put(teamId, playerList);
}
playerList.add(playerId);
tmpTeamID = cRset.getString("TEAM_ID");
}
}
catch(SQLException sqle){
throw new Exception(sqle, "Error While Selecting Team-Player Mapping");
}
return teamPlayer ;
}

Part two – Converting XML document/tags into java objects in hierarchy/ structure. Same initialization code will be used to identify the xml tags, and the java objects in which values/attributes of xml tags are supposed to be assigned.


String xml = "<team-player-mapping>"+ " <team id="413">"+ " <player>ASIF</player>"+ " <player>RAM</player>"+ " <player>GOLDU</player>"+ " <player>VIKY</player>"+ " <player>AJAY</player>"+ " <player>MANOJ</player>"+ " </team>"+ " <team id="410">"+ " <player>AKRAM</player>"+ " <player>MOHAN</player>"+ " <player>KISHOR</player>"+ " </team>"+ " <team id="408">"+ " <player>RIK</player>"+ " <player>ASTER</player>"+ " <player>FOSTER</player>"+ " <player>FSCP</player>"+ " </team>"+ "</team-player-mapping>";

To reconstruct an object, purely from the XML: TeamPlayerMapping teamPlayerMapping = (TeamPlayerMapping )xstream.fromXML(xml);

Conclusion is, only initialization part is most critical. Once it is done the Serialization and de-serialization can be done very easily. This is very elementary detail/tutorial about using XStream. More can be found on web.

SCWCD Notes - Web App Deployment

Tag Files- Must be deployed in WEB-INF/tags folder or subfolder. In case of jar it should be in META-INF/tags folder or subfolder.
If tag file is put anywhere else the container will recognise it as a static content.

Library Dependencies - In WAR file, META-INF/MANIFEST.MF is used to declare the library dependencies. It gives the deploy-time check for whether the container can find the packages and classes our app depends on.
Even if we dont put the META-INF directory in WAR, after deployment when the WAR is exploded, then META-INF and MANIFEST.MF is created inside that.

Server returns 404 Page not found error, if anything inside META-INF or WEB-INF is requested by client. But we can keep here active contents which can be included or forwarded by other jsp page, but client cannot request them directly.

Container will always looks for classes in WEB-INF/classes directry then it will go to WEB-INF/lib directory for jars.

classloader's getResource() and getResourceAsStream() methods can be used to access a resource (text file, JPEG etc) that's also inside a JAR. These methods are also inServletContext, but they work only for the resources which are not deployed in the jar file.

Servlet Mapping - <servlet-name>is mapped to <url-pattern>. <servlet-name>is the key and every request is come to <url-pattern>which picks the servlet associated with <servlet-name>
Three types of url pattern are their. The container looks for the matches in the given below order of match-pattern. First it chooses exact match, if its not found then opts for directory match and after al last it goes for extension match.

  1. Exact Match: Must begin with slash(/), may have an extension but not mandatory. e.g.<url-pattern>/beer/selectBeer.do
  2. Directory Match: Must begin with an slash(/). The directory can be real or virtual. It ends with slash(/) or *. e.g. <url-pattern>/beer/*.
  3. Extension Match: Must begin with an * (never with slash) . After the * it must have an dot(.) extension. e.g. <url-pattern>*.do.

Lastly the most specific match wins. for example request for /foo/bar/mystuff.do will also matc /foo/bar/* and /foo/*. But the first one will be selected because its more specific to the request.

Configuring Welcome files in DD: welcome files are default page, they appear when only name of website is given in URL without specifying any URL. For example entering <a href="http://www.yahoo.com/">http://www.yahoo.com/</a> will take to yahoo home page, here home page is welcome file of the yahoo web application.

The files in the <welcome-file>do not start with a slash. Multiple welcome files <welcome-file>go in a single DD element <welcome-file-list>.<welcome-file-list>
<web-app...>
<welcome-file>
<welcome-file-list>
<welcome-file>index.html </welcome-file>
<welcome-file>deault.jsp </welcome-file>
</welcome-file-list>
</web-app>

Now if the web-app is having diffenerent direcotries, we don't need to specify default html or jsp pages for them separately. All default pages will be specified in on place in <welcome-file-list>and container will choose first page matching to the request. For every request container first looks for servlet url mapping, if iti doesnot finds any match then opts to scan <welcome-file-list>

webapps/MyTestApp/index.html
webapps/MyTestApp/search/default.jsp
webapps/MyTestApp/registration/index.html
webapps/MyTestApp/registration/newMember/foo.txt

Request: <a href="http://localhost:8080/MyTestApp/">http://localhost:8080/MyTestApp/</a>
Container: Choice: MyTestApp/index.html
Request: <a href="http://localhost:8080/MyTestApp/registation">http://localhost:8080/MyTestApp/registation</a>
Container: Choice: MyTestApp/registration/index.html
Request: <a href="http://localhost:8080/MyTestApp/search">http://localhost:8080/MyTestApp/search</a>
Container: Choice: MyTestApp/search/default.jsp(if index.html and default.jsp both would be in search direcotry then container will take index.html)
Request: <a href="http://localhost:8080/registration/newMember">http://localhost:8080/registration/newMember</a>
Container: Choice: When no files from <welcome-file-list>is specified the behaviou r vendor specific. Tomcat shows directory list, another container may shoe 404 error.

Configuring Error Pages in DD: Used to display freindly message when any error/exception happens.

catch-all error page: applies to everything in web app- not just in jsps. Anything thatsThrowable can be declared in <exception-type>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>
(this can be overridden in original jsp by adding a page directive with an errorPage attribute)
Explicit exception error page: for example, follwing error page will be called only when there's ArithmeticExcption, for all other exceptions te first error page will be called (Throwable)
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/arithmeticError.jsp</location>
</error-page>
HTTP statuc code error page: for example, following error page will come when the status code for the response is 404. HttpServletResponse.sendError(402) can also be used to send own response code and pull the pages from <error-page> tag.
<error-page>
<error-code>404</error-code>
<location>/arithmeticError.jsp</location>
</error-page>
response.sendError(HttpServletresponse.SC_FORBIDDEN); and response.sendError(403); are same.

Note: We cannot have both status code and exception type in single <error-page>tag.

</web-app>Configuring Servlet initialization in DD: Servlets are initialized at first request. So when the first client requests a servlet, class loading, instantiation and initalization happens of a servlet, before service() method can be invoked.

To load servlet on deploy time <load-on-startup> element is used in DD.

<servlet>
<servlet-name>one</servlet-name>
<servlet-class>com.sanjeev.One</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>two</servlet-name>
<servlet-class>com.sanjeev.Two</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

Now the servelt one will be loaded first then servlet two will be loaded durig deployment. Any number greater than zero in <load-on-startup> element assists the servlet to be initailized during deployment.

Writing XML compilant JSP:

  1. <%@page import="java.util.*" %> --- <jsp:directive.page import="java.util.*" />
  2. <%! int y=3; %> ---- <jsp:declaration>int y=3;</jsp:declaration>
  3. <% list.add("Hoop"); > ---- <jsp:scriptlet>list.add("Hoop");</jsp:scriptlet>
  4. There is no spoon ---- <jsp:text>There is no spoon</jsp:text>
  5. <= it.next() %> ---- <jsp:expression> it.next() </jsp:expression >

Refering EJBs in web-app:

Local Beans : <ejb-local-ref>
<ejb-ref-name>ejb/Customer</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.java.customerHome</local-home>
<local>com.java.Customer</local>
</ejb-local-ref>

Remote Beans :<ejb-ref>
<ejb-ref-name>ejb/Customer</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.java.customerHome</home>
<remote>com.java.Customer</remote>
</ejb-ref>

Env Entry: <env-entry>
<env-entry-name>rates/discountRate</env-entry-name>
<env-entry-type>java.lang.Integer<env-entry-type>
<env-entry-value>10</env-entry-value>
</env-entry>

<env-entry-name>- This will be used in code to lookup entry.
<env-entry-type>- It can be any type that takes a single String as a constructor parameter or a single character if the type is java.lang.Character.
<env-entry-value>- It will be passed in as String or a single character if the is java.lang.Character.

Note that its not only primitive type or wrapper type. It can be any type which have single String as parameter constructor.

Configuring Mime type mapping: mapping between extension and the mime type.

<mime-mapping>
<extension>mpg</extension> <!-- do not include the dot "." -->
<mime-type>video/mpeg</mime-type>
</mime-mapping>

SCWCD Notes - Security

Type of Bad guys (for whome securiy is needed) -
  1. Impersonator- Pretends to be some exsisting user and breaks into the system.
  2. Upgrader - Existing user, breachs security and upgrades his rights to avail more facility.
  3. Evasdropper - They steal information of clients and misuse them for example stealing credit card info and using.

Four Points in Servlet Security-

  1. Authentication (user/password) - Validates identity of user and is meant for Impersonators.
  2. Autherization - Filters the rights/accessibility of users and is for Upgraders.
  3. Confidentiality- Securing data e.g. encryption. Used to foil evasdroppers.
  4. Data Integrity - Used to foil evasdroppers.

Authentication in HTTP: how browser and web server communicate?

  1. Browser requests for "update.jsp". After receiving the request container finds the
    URL in security table.
  2. If entry found in security table, server checks if the resource is constrained.
  3. Constrained yes then server
    send 401("Unauthorized"), with a www-authenticate header and realm info.
  4. Browser gets 401 and after getting realm info asks for username password.
  5. Browser again asks for "update.jsp" but with security HTTP header and username and
    password. Container receives the request and checks the URL in security table.
  6. If URL found in security table, that resource is constrained and checks for username and password to make sure they match.
  7. If username password matches container checks for role i.e. authoraization and returns
    "update.jsp" if role has access to the page. Otherwise 401 is returned.

Implementing Security in web-app
Who
:
Servlet Provider : No need to bother about security.
Administrator: Determines the type of roles and descriptions. For example Guest, Member,Admin. Authentication is done by admin.
Deployer: Determines which role will access which resource/servlet. Last three i.e. authorization, confidentiality and data integrity are done by deployer.

Authentication: A users can't be authorized until he is authenticated. Servlet spec doesn't talk about how the container should implement authentication, its all vendor dependent how to keep data of username and password.
realm: This is the place where where authentication info(user/password table) is stored. For example tomcat keeps all authentication data in conf/tomcat-users.xml and it applies to all web apps deployed in the servler. this file is not kept in any web-app directory. This is called as memory realm because tomcat loads this file in memory at startup.
&lt;tomcat-users&gt;
&lt;role rolename="Guest"/&gt;
&lt;role rolename="Member"/&gt;
&lt;user name="Bill" password="coder" roles="Member, Guest" /&gt;
...
&lt;/tomcat-users&gt;

Remember, this is not part of DD.

Enabling Authentication: If you want container to ask user name and password, following need to be written in DD.
&lt;login-config&gt;
&lt;auth-method&gt;BASIC&lt;/auth-method&gt;
&lt;/login-config&gt;

DB2 Basic Essentails

Listing the details(metadata) of a table.
SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = ‘MYTABLE’ AND TBCREATOR = ‘MYSCHEMA’ ORDER BY COLNO
where TBNAME is table name and TBCREATOR is schema name

Listing column name, column type, size, tablename of column of a table
SELECT name, coltype, length, tbname FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = ‘MYTABLE’ AND TBCREATOR = ‘MYSCHEMA’ ORDER BY name

Selecting current date and current time
SELECT CURRENT DATE, CURRENT TIME FROM MYSCHEMA.MYTABLE

Using current date, current time in insert query
INSERT INTO MYSCHEMA.MYTABLE(MYDATE, MYTIME) VALUES (CURRENT TIME, CURRENT DATE)

Using java.math.BigDecimal

BigDecimal is a wrapper class over double data type. As Java is having Double wrapper class but still we need to use BigDecimal when precision comparison and other mathematical operation on Double objects (not native data type is required)

BigDecimal is required when the value of double datatype need to be passed in Object form (not in native form). This requirement comes when you do some file operation or you need to pass data over network or distributed application. We can use java.lang.Doublealso when we don’t need to change or manipulate the data contained in Object. But when there are operations like Comparison, addition, multiplication and maintaining precision then I will recommend BigDecimal in place of Double.

BigDecimal contains methods to add, subtract, multiply, divide and compare BigDecimal objects (Java doc link: http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html). The methods internally maintain the precisions and Rounding of Parameters which are already present in the Object.

Double (Java doc link: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html)is not having such kind of methods and does not maintain precision when you convertDouble wrapper object todouble native value for mathematical operation. Double is having methods to convert double value to String and object value to double and int.

Similarities:Both Doubleand BigDecimal are immutable, i.e. if you do any operation on these objects it does not apply on them unless and until you reassign the new value in them. For example if you want to setScale in a BigDecimal, it won’t get reflected if you don’t reassign the value in old reference.

BigDecimal bd = new BigDecimal(0);

bd.setScale(2, BigDecimal.ROUND_HALF_EVEN);

The statement above will not change the object and it will hold the old precision. To get the effect of the method above try this

bd = bd.setScale(2, BigDecimal.ROUND_HALF_EVEN);

One more thing I would like to add regarding the uniform usability of BigDecimal across the application.

Store the parameters of setScale method in some property or constant and use those property while setting the precision or scale. This will maintain the uniform values and precision of BigDecimal across the application.

For Example instead of statement above use the following coding style:

final static int BIG_DECIMAL_PRECISION_2 = 2;

final static int BIG_DECIMAL_ROUNDING_MODE_HALF_EVEN = BigDecimal.ROUND_HALF_EVEN;

BigDecimal bd = new BigDecimal(0);

bd = bd.setScale(final static int BIG_DECIMAL_PRECISION_2, BIG_DECIMAL_ROUNDING_MODE_HALF_EVEN);

DB2 - SQL Error Code and Description

01002 A DISCONNECT error occurred.
01003 Null values were eliminated from the argument of a column function.
01004 The value of a string was truncated when assigned to another string data type with a shorter length.
01005 Insufficient number of entries in an SQLDA.
01007 A privilege was not granted.
0100C One or more adhoc result sets were returned from the procedure.
0100D The cursor that was closed has been re-opened on the next result set within the chain.
0100E The procedure generated more than the maximum allowed number of result sets. Only the first integer result sets have been returned to the caller.
01503 The number of result columns is larger than the number of host variables provided.
01504 The UPDATE or DELETE statement does not include a WHERE clause.
01506 An adjustment was made to a DATE or TIMESTAMP value to correct an invalid date resulting from an arithmetic operation.
01509 Blocking was cancelled for a cursor because there is insufficient storage in the user virtual machine.
01515 The null value has been assigned to a host variable, because the non-null value of the column is not within the range of the host variable.
01516 An inapplicable WITH GRANT OPTION has been ignored.
01517 A character that could not be converted was replaced with a substitute character.
01519 The null value has been assigned to a host variable, because a numeric value is out of range.
01524 The result of a column function does not include the null values that were caused by evaluating an arithmetic expression.
01526 Isolation level has been escalated.
01527 A SET statement references a special register that does not exist at the AS.
01539 Connection is successful but only SBCS characters should be used.
01543 A duplicate constraint has been ignored.
01545 An unqualified column name has been interpreted as a correlated reference.
01550 The index was not created, because an index with the specified description already exists.
01560 A redundant GRANT has been ignored.
01562 The new path to the log (newlogpath) in the database configuration file is invalid.
01563 The current path to the log file (logpath) is invalid. The log file path is reset to the default.
01564 The null value has been assigned to a host variable, because division by zero occurred.
01586 Setting OFF the constraints for a parent table in a referential structure has resulted in one or more descendent tables being automatically placed into a check-pending state
01589 A statement contains redundant specifications.
01592 In a CREATE FUNCTION statement that references a SOURCE function, either:
an input parameter has a larger length, precision, or scale than that of the corresponding parameter of the source function; or
the RETURNS or CAST FROM parameter has a smaller length, precision, or scale than that of the source function; or
the CAST FROM parameter in the CREATE FUNCTION statement has a larger length, precision, or scale than that of the RETURNS parameter.
Truncation may occur at run time (and may result in an error at that time).
01594 Insufficient number of entries in an SQLDA for ALL information (i.e. not enough descriptors to return the distinct name).
01595 The view has replaced an existing, invalidated view.
01596 Comparison functions were not created for a distinct type based on a long string data type.
01598 An attempt has been made to activate an active event monitor or deactivate an inactive event monitor.
01599 Bind options were ignored on REBIND.
01602 The optimization level has been reduced.
01603 CHECK DATA processing found constraint violations and moved them to exception tables.
01604 The SQL statement was explained and not executed.
01605 A recursive common table expression may contain an infinite loop.
01606 The node or system database directory is empty.
01607 The difference between the times on nodes in a read-only transactions exceed the defined threshold.
01609 The procedure generated more than the maximum allowed number of result sets. Only the first integer result sets have been returned to the caller.
01610 One or more ad hoc result sets were returned from the procedure.
01611 The cursor that was closed has been re-opened on the next result set within the chain.
01614 There are fewer locators than the number of result sets.
01616 The estimated CPU cost exceeds the resource limit.
01618 Redistribute nodegroup is required to change data partitioning.
01620 Some base tables of UNION ALL may be the same table.
01621 The retrieved LOB value may have been changed.
01622 Statement completed successfully but a system error occurred after the statement completed.
01623 Value of DEGREE is ignored.
01625 The schema name appears more than once in the CURRENT PATH.
01626 The database has only one active bufferpool.
01627 The DATALINK value may not be valid because the table is in reconcile pending or reconcile is not possible state.
01632 The number of concurrent connections has exceeded the defined entitlement for the product.
01633 The materialized query table may not be used to optimize the processing of queries.
01636 Integrity of non-incremental data remains unverified by the database manager.
01637 Debugging is not enabled.
01639 The federated object may require the invoker to have necessary privileges on data source objects.
01641 Datalink type attributes limit the use of the structured type.
01642 Column not long enough for the largest possible USER default value.
01643 Assignment to an SQLSTATE or SQLCODE variable in an SQL routine may be over-written and does not activate any handler.
01645 The executable for the SQL procedure is not saved in the database catalog.
01648 COMPRESS column attribute ignored because VALUE COMPRESSION is deactivated for the table.
01649 The buffer pool operation has been completed but will not take effect until the next database restart.
01650 Index and table statistics are inconsistent.
01651 The event monitor was activated successfully, however some monitoring information may be lost.
01652 The isolation clause is ignored because of the statement context.
01653 The authorizations were granted to USER. Groups were not considered because the authorization name is more than 8 bytes.
01654 The buffer pool is not started.
01655 The event monitor was created successfully but at least one event monitor target table already exists.
01657 The bufferpool operation will not take effect until the next database startup.
01665 The column name or parameter name was truncated.
01667 The view may not be used to optimize the processing of queries.
01669 The statistics for the specified nicknames were not updated completely because of schema inconsistencies between the remote and local catalogs.
01670 No default primary table space exists for the new table.
01671 The environment of the cached statement is different than the current environment. The current environment will be used to reoptimize the specified statement.
01H51 An MQSeries Application Messaging Interface message was truncated.
01HXX Valid warning SQLSTATEs returned by a user-defined function or external procedure CALL.

Class Code 02 No Data
Table 5. Class Code 02: No Data SQLSTATE Value
Meaning
02000 One of the following exceptions occurred:
The result of the SELECT INTO statement or the subselect of the INSERT statement was an empty table.
The number of rows identified in the searched UPDATE or DELETE statement was zero.
The position of the cursor referenced in the FETCH statement was after the last row of the result table.

02501 The cursor position is not valid for a FETCH of the current row.
02502 Delete or update hole detected

Class Code 07 Dynamic SQL Error
Table 6. Class Code 07: Dynamic SQL Error SQLSTATE Value
Meaning
07001 The number of host variables is not correct for the number of parameter markers.
07002 The call parameter list or control block is invalid.
07003 The statement identified in the EXECUTE statement is a select-statement, or is not in a prepared state.
07004 The USING clause or the INTO clause is required for dynamic parameters.
07005 The statement name of the cursor identifies a prepared statement that cannot be associated with a cursor.
07006 An input host variable cannot be used, because of its data type.

Class Code 08 Connection Exception
Table 7. Class Code 08: Connection Exception SQLSTATE Value
Meaning
08001 The application requester is unable to establish the connection.
08002 The connection already exists.
08003 The connection does not exist.
08004 The application server rejected establishment of the connection.
08007 Transaction resolution unknown.
08502 The CONNECT statement issued by an application process running with a SYNCPOINT of TWOPHASE has failed, because no transaction manager is available.
08504 An error was encountered while processing the specified path rename configuration file.

Class Code 09 Triggered Action Exception
Table 8. Class Code 09: Triggered Action Exception SQLSTATE Value
Meaning
09000 A triggered SQL statement failed.

Class Code 0A Feature Not Supported
Table 9. Class Code 0A: Feature Not Supported SQLSTATE Value
Meaning
0A001 The CONNECT statement is invalid, because the process is not in the connectable state.
0A502 The action or operation is not enabled for this database instance.
0A503 Federated insert, update, or delete operation cannot be compiled because of potential data inconsistency.

Class Code 0D Invalid Target Type Specification
Table 10. Class Code 0D: Invalid Target Type Specification SQLSTATE Value
Meaning
0D000 The target structured data type specification is a proper subtype of the source structured data type.

Class Code 0F Invalid Token
Table 11. Class Code 0F: Invalid Token SQLSTATE Value
Meaning
0F001 The LOB token variable does not currently represent any value.

Class Code 0K Invalid RESIGNAL statement
Table 12. Class Code 0K: Invalid RESIGNAL statement SQLSTATE Value
Meaning
0K000 RESIGNAL statement is not within a handler.

Class Code 20 Case Not Found for Case Statement
Table 13. Class Code 20: Case Not Found for Case Statement SQLSTATE Value
Meaning
20000 The case was not found for the CASE statement.

Class Code 21 Cardinality Violation
Table 14. Class Code 21: Cardinality Violation SQLSTATE Value
Meaning
21000 The result of a SELECT INTO is a result table of more than one row, or the result of the subquery of a basic predicate is more than one value.
21501 A multiple-row INSERT into a self-referencing table is invalid.
21502 A multiple-row UPDATE of a primary key is invalid.
21504 A multiple-row DELETE from a self-referencing table with a delete rule of RESTRICT or SET NULL is invalid.
21505 A row function must return not more than one row.
21506 The same row of a table cannot be the target for more than one of an update, delete or insert operation.

Class Code 22 Data Exception
Table 15. Class Code 22: Data Exception SQLSTATE Value
Meaning
22001 Character data, right truncation occurred; for example, an update or insert value is a string that is too long for the column, or a datetime value cannot be assigned to a host variable, because it is too small.
22002 A null value, or the absence of an indicator parameter was detected; for example, the null value cannot be assigned to a host variable, because no indicator variable is specified.
22003 A numeric value is out of range.
22004 A null value cannot be returned either from a procedure defined as PARAMETER STYLE GENERAL, or from a type-preserving method invoked with a non-null argument.
22007 An invalid datetime format was detected; that is, an invalid string representation or value was specified.
22008 Datetime field overflow occurred; for example, an arithmetic operation on a date or timestamp has a result that is not within the valid range of dates.
2200G The most specific type does not match.
22011 A substring error occurred; for example, an argument of SUBSTR is out of range.
22012 Division by zero is invalid.
22018 The character value for the CAST, DECIMAL, FLOAT, or INTEGER scalar function is invalid.
22019 The LIKE predicate has an invalid escape character.
22021 A character is not in the coded character set.
22024 A NUL-terminated input host variable or parameter did not contain a NUL.
22025 The LIKE predicate string pattern contains an invalid occurrence of an escape character.
2202D Null instance used with a mutator method.
2202H The sample size in the TABLESAMPLE clause is invalid.
22501 The length control field of a variable length string is negative or greater than the maximum.
22504 A mixed data value is invalid.
22506 A reference to a datetime special register is invalid, because the TOD clock is malfunctioning or the operating system timezone parameter is out of range.
22522 A CCSID value is not valid at all, not valid for the data type or subtype, or not valid for the encoding scheme.
22526 A key transform function generated no rows or duplicate rows.
22527 Invalid input data detected for a multiple row INSERT operation.

Class Code 23 Constraint Violation
Table 16. Class Code 23: Constraint Violation SQLSTATE Value
Meaning
23001 The update or delete of a parent key is prevented by a RESTRICT update or delete rule.
23502 An insert or update value is null, but the column cannot contain null values.
23503 The insert or update value of a foreign key is invalid.
23504 The update or delete of a parent key is prevented by a NO ACTION update or delete rule.
23505 A violation of the constraint imposed by a unique index or a unique constraint occurred.
23510 A violation of a constraint on the use of the command imposed by the RLST table occurred.
23511 A parent row cannot be deleted, because the check constraint restricts the deletion.
23512 The check constraint cannot be added, because the table contains rows that do not satisfy the constraint definition.
23513 The resulting row of the INSERT or UPDATE does not conform to the check constraint definition.
23514 Check data processing has found constraint violations.
23515 The unique index could not be created or unique constraint added, because the table contains duplicate values of the specified key.
23520 The foreign key cannot be defined, because all of its values are not equal to a parent key of the parent table.
23521 The update of a catalog table violates an internal constraint.
23522 The range of values for an identity column or sequence is exhausted.
23524 Invalid row movement within the UNION ALL view.
23527 Integrity constraint violated at the federated data source.

Class Code 24 Invalid Cursor State
Table 17. Class Code 24: Invalid Cursor State SQLSTATE Value
Meaning
24501 The identified cursor is not open.
24502 The cursor identified in an OPEN statement is already open.
24504 The cursor identified in the UPDATE, DELETE, SET, or GET statement is not positioned on a row.
24506 The statement identified in the PREPARE is the statement of an open cursor.
24510 An UPDATE or DELETE operation was attempted against a delete hole or update hole.
24512 The result table does not agree with base table.
24513 FETCH NEXT, PRIOR, CURRENT or RELATIVE is not allowed because the cursor position is not known.
24514 A previous error has disabled this cursor.
24516 A cursor has already been assigned to a result set.
24517 A cursor was left open by an external function or method.

Class Code 25 Invalid Transaction State
Table 18. Class Code 25: Invalid Transaction State SQLSTATE Value
Meaning
25000 An insert, update, or delete operation is invalid in the context where it is specified.
25001 The statement is only allowed as the first statement in a unit of work.
25501 The statement is only allowed as the first statement in a unit of work.
25502 Operation cannot occur multiple times in a single transaction.

Class Code 26 Invalid SQL Statement Identifier
Table 19. Class Code 26: Invalid SQL Statement Identifier SQLSTATE Value
Meaning
26501 The statement identified does not exist.

Class Code 27 Triggered Data Change Violation
Table 20. Class Code 27: Triggered Data Change Violation SQLSTATE Value Meaning
27000 An attempt was made to modify the target table of the MERGE statement by a constraint or trigger.

Class Code 28 Invalid Authorization Specification
Table 21. Class Code 28: Invalid Authorization Specification SQLSTATE Value
Meaning
28000 Authorization name is invalid.

Class Code 2D Invalid Transaction Termination
Table 22. Class Code 2D: Invalid Transaction Termination SQLSTATE Value
Meaning
2D521 SQL COMMIT or ROLLBACK are invalid in the current operating environment.
2D522 COMMIT and ROLLBACK are not allowed in an ATOMIC Compound statement.
2D528 Dynamic COMMIT is invalid for the application execution environment.
2D529 Dynamic ROLLBACK is invalid for the application execution environment.

Class Code 2E Invalid Connection Name
Table 23. Class Code 2E: Invalid Connection Name SQLSTATE Value
Meaning
2E000 Connection name is invalid.

Class Code 34 Invalid Cursor Name
Table 24. Class Code 34: Invalid Cursor Name SQLSTATE Value
Meaning
34000 Cursor name is invalid.

Class Code 36 Invalid Cursor Specification
Table 25. Class Code 36: Invalid Cursor Specification SQLSTATE Value
Meaning
36001 A SENSITIVE cursor cannot be defined for the specified select-statement.

Class Code 38 External Function Exception
Table 26. Class Code 38: External Function Exception SQLSTATE Value
Meaning
38XXX Valid error SQLSTATEs returned by an external routine, or trigger.
38001 The external routine is not allowed to execute SQL statements.
38002 The routine attempted to modify data, but the routine was not defined as MODIFIES SQL DATA.
38003 The statement is not allowed in a routine.
38004 The routine attempted to read data, but the routine was not defined as READS SQL DATA.
38501 Error occurred while calling a user-defined function, external procedure, or trigger (using the SIMPLE CALL or SIMPLE CALL WITH NULLS calling convention).
38502 The external function is not allowed to execute SQL statements.
38503 A user-defined function has abnormally terminated (abend).
38504 A user-defined function has been interrupted by the user to stop a probable looping condition.
38505 An SQL statement is not allowed in a routine on a FINAL CALL.
38506 Function failed with error from OLE DB provider.
38552 A function in the SYSFUN schema (supplied by IBM) has abnormally terminated.
One of the following reason codes can be found in the message text:

01
Numeric value out of range
02
Division by zero
03
Arithmetic overflow or underflow
04
Invalid date format
05
Invalid time format
06
Invalid timestamp format
07
Invalid character representation of a timestamp duration
08
Invalid interval type (must be one of 1, 2, 4, 8, 16, 32, 64, 128, 256)
09
String too long
10
Length or position in string function out of range
11
Invalid character representation of a floating point number
38553 A routine in a system schema has terminated with an error.
38H01 An MQSeries function failed to initialize.
38H02 MQSeries Application Messaging Interface failed to terminate the session.
38H03 MQSeries Application Messaging Interface failed to properly process a message.
38H04 MQSeries Application Messaging Interface failed in sending a message.
38H05 MQSeries Application Messaging Interface failed to read/receive a message.
38H06 An MQSeries Application Messaging Interface (un)subscription request failed.
38H07 MQSeries Application Messageing Inteface failed to commit the unit of work.
38H08 MQSeries Application Messaging Interface policy error.
38H09 MQSeries XA (two phase commit) API call error.
38H0A MQSeries Application Messaging Interface failed to roll back the unit of work.

Class Code 39 External Function Call Exception
Table 27. Class Code 39: External Function Call Exception SQLSTATE Value
Meaning
39001 A user-defined function has returned an invalid SQLSTATE.
39004 A null value is not allowed for an IN or INOUT argument.
39501 The eye-catcher associated with an argument was modified.

Class Code 3B Invalid SAVEPOINT
Table 28. Class Code 3B: Invalid SAVEPOINT SQLSTATE Value
Meaning
3B001 The savepoint is not valid.
3B002 The maximum number of savepoints has been reached.
3B501 A duplicate savepoint name was detected.
3B502 A RELEASE or ROLLBACK TO SAVEPOINT was specified, but a savepoint does not exist.
3B503 A SAVEPOINT, RELEASE SAVEPOINT, or ROLLBACK TO SAVEPOINT is not allowed in a trigger or global transaction.

Class Code 40 Transaction Rollback
Table 29. Class Code 40: Transaction Rollback SQLSTATE Value
Meaning
40001 Deadlock or timeout with automatic rollback occurred.
40003 The statement completion is unknown.
40504 A system error has caused the unit of work to be rolled back.
40506 The current transaction was rolled back because of an SQL error.
40507 The current transaction was rolled back as a result of a failure creating an index.

Class Code 42 Syntax Error or Access Rule Violation
Table 30. Class Code 42: Syntax Error or Access Rule Violation SQLSTATE Value
Meaning
42501 The authorization ID does not have the privilege to perform the specified operation on the identified object.
42502 The authorization ID does not have the privilege to perform the operation as specified.
42504 A specified privilege cannot be revoked from a specified authorization-name.
42506 Owner authorization failure occurred.
42508 The specified database privileges cannot be granted to PUBLIC.
42509 SQL statement is not authorized, because of the STATICRULES option.
42511 Unable to retrieve a DATALINK value.
42601 A character, token, or clause is invalid or missing.
42602 A character that is invalid in a name has been detected.
42603 An unterminated string constant has been detected.
42604 An invalid numeric or string constant has been detected.
42605 The number of arguments specified for a scalar function is invalid.
42606 An invalid hexadecimal constant has been detected.
42607 An operand of a column function is invalid.
42608 The use of NULL or DEFAULT in VALUES is invalid.
42609 All operands of an operator or predicate are parameter markers.
42610 A parameter marker is not allowed.
42611 The column or argument definition is invalid.
42612 The statement string is an SQL statement that is not acceptable in the context in which it is presented.
42613 Clauses are mutually exclusive.
42614 A duplicate keyword is invalid.
42615 An invalid alternative was detected.
42616 Invalid options are specified.
42617 The statement string is blank or empty.
42618 A host variable is not allowed.
42620 Read-only SCROLL was specified with the UPDATE clause.
42621 The check constraint is invalid.
42622 A name or label is too long.
42623 A DEFAULT clause cannot be specified.
42625 A CASE expression is invalid.
42627 RETURNS clause must be specified prior to predicate specification using the EXPRESSION AS clause.
42628 A TO SQL or FROM SQL transform function is defined more than once in a transform definition.
42629 Parameter names must be specified for SQL routines.
42630 An SQLSTATE or SQLCODE variable declaration must not be in a nested compound statement.
42631 A RETURN statement in an SQL function or method must include a return value.
42634 The XML name is not valid.
42635 The XML namespace prefix is not valid.
42701 A duplicate column name in an insert or update operation or the SET transition-variable statement was detected.
42702 A column reference is ambiguous, because of duplicate names.
42703 An undefined column, attribute, or parameter name was detected.
42704 An undefined object or constraint name was detected.
42705 An undefined server-name was detected.
42707 A column name in ORDER BY does not identify a column of the result table.
42709 A duplicate column name in a PRIMARY, UNIQUE, or FOREIGN KEY clause was detected.
42710 A duplicate object or constraint name was detected.
42711 Duplicate column name or attribute name was detected in the object definition or ALTER statement.
42712 A duplicate table designator was detected in the FROM clause.
42713 A duplicate object was detected in a list of objects.
42720 The nodename for the remote database was not found in the node directory.
42723 A function with the same signature already exists in the schema.
42724 Unable to access an external program used for a user-defined function or a procedure.
42725 A function or method was referenced directly (not by either signature or by specific instance name), but there is more than one specific instance of that function or method.
42726 Duplicate names for named derived tables were detected.
42727 No default primary tablespace exists for the new table.
42728 A duplicate node was detected in the nodegroup definition.
42729 The node is not defined.
42730 The container name is already used by another tablespace.
42731 The container name is already used by this tablespace.
42732 A duplicate schema name in the SET CURRENT PATH statement was detected.
42734 A duplicate parameter-name, SQL variable-name, cursor-name, condition-name, or label was detected.
42735 Nodegroup for the table space is not defined for the buffer pool.
42736 The label specified on the LEAVE statement is not found or not valid.
42737 The condition specified in the handler is not defined.
42738 A duplicate column name or unnamed column was specified in a DECLARE CURSOR statement of a FOR statement.
42739 A duplicate transform was detected.
42740 No transforms were found for the specified type. No transforms were dropped.
42741 A transform group is not defined for a data type.
42742 Subtable or subview of the same type already exists in the typed table or typed view hierarchy.
42743 The search method is not found in the index extension.
42744 A TO SQL or FROM SQL transform function is not defined in a transform group.
42745 The routine would define an overriding relationship with an existing method.
42746 A method name cannot be the same as a structured type name within the same type hierarchy.
42748 The storage path already exists for the database or it is specified more than once.
42802 The number of insert or update values is not the same as the number of columns.
42803 A column reference in the SELECT or HAVING clause is invalid, because it is not a grouping column; or a column reference in the GROUP BY clause is invalid.
42804 The result expressions in a CASE expression are not compatible.
42805 An integer in the ORDER BY clause does not identify a column of the result table.
42806 A value cannot be assigned to a host variable, because the data types are not compatible.
42807 The INSERT, UPDATE, or DELETE is not permitted on this object.
42808 A column identified in the insert or update operation is not updateable.
42809 The identified object is not the type of object to which the statement applies.
42810 A base table is not identified in a FOREIGN KEY clause.
42811 The number of columns specified is not the same as the number of columns in the SELECT clause.
42813 WITH CHECK OPTION cannot be used for the specified view.
42815 The data type, length, scale, value, or CCSID is invalid.
42816 A datetime value or duration in an expression is invalid.
42818 The operands of an operator or function are not compatible.
42819 An operand of an arithmetic operation or an operand of a function that requires a number is not a number.
42820 A numeric constant is too long, or it has a value that is not within the range of its data type.
42821 An update or insert value is not compatible with the column.
42823 Multiple columns are returned from a subquery that is allowed only one column.
42824 An operand of LIKE is not a string, or the first operand is not a column.
42825 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have compatible columns.
42826 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have the same number of columns.
42827 The table identified in the UPDATE or DELETE is not the same table designated by the cursor.
42828 The table designated by the cursor of the UPDATE or DELETE statement cannot be modified, or the cursor is read-only.
42829 FOR UPDATE OF is invalid, because the result table designated by the cursor cannot be modified.
42830 The foreign key does not conform to the description of the parent key.
42831 A column of a primary or unique key cannot allow null values.
42832 The operation is not allowed on system objects.
42834 SET NULL cannot be specified, because no column of the foreign key can be assigned the null value.
42835 Cyclic references cannot be specified between named derived tables.
42836 The specification of a recursive, named derived table is invalid.
42837 The column cannot be altered, because its attributes are not compatible with the current column attributes.
42838 An invalid use of a tablespace was detected.
42839 Indexes and long columns cannot be in separate tablespaces from the table.
42840 An invalid use of the AS CAST option was detected.
42841 A parameter marker can not be a user-defined type or reference type.
42842 A column definition is invalid, because a specified option is inconsistent with the column description.
42845 An invalid use of a VARIANT or EXTERNAL ACTION function was detected.
42846 Cast from source type to target type is not supported.
42852 The privileges specified in GRANT or REVOKE are invalid or inconsistent. (For example, GRANT ALTER on a view.)
42853 Both alternatives of an option were specified, or the same option was specificed more than once.
42854 A result column data type in the select list is not compatible with the defined type in a typed view or materialized query table definition.
42855 The assignment of the LOB to this host variable is not allowed. The target host variable for all fetches of this LOB value for this cursor must be a locator or a LOB variable.
42858 Operation cannot be applied to the specified object.
42863 An undefined host variable in REXX has been detected.
42866 The data type in either the RETURNS clause of the CAST FROM clause in the CREATE FUNCTION statement is not appropriate for the data type returned from the sourced function or RETURN statement in the function body.
42867 Conflicting options have been specified.
42872 FETCH statement clauses are incompatible with the cursor definition.
42875 The object to create within CREATE SCHEMA must have the same qualifier as the schema name.
42877 The column name cannot be qualified.
42878 An invalid function or procedure name was used with the EXTERNAL keyword.
42879 The data type of one or more input parameters in the CREATE FUNCTION statement is not appropriate for the corresponding data type in the source function.
42880 The CAST TO and CAST FROM data types are incompatible, or would always result in truncation of a fixed string.
42881 Invalid use of a row based function.
42882 The specific instance name qualifier is not equal to the function name qualifier.
42883 No function or method was found with a matching signature.
42884 No routine was found with the specified name and compatible arguments.
42885 The number of input parameters specified on a CREATE FUNCTION statement does not match the number provided by the function named in the SOURCE clause.
42886 The IN, OUT, or INOUT parameter attributes do not match.
42887 The function is not valid in the context where it occurs.
42888 The table does not have a primary key.
42889 The table already has a primary key.
42890 A column list was specified in the references clause, but the identified parent table does not have a unique constraint with the specified column names.
42891 A duplicate UNIQUE constraint already exists.
42893 The object or constraint cannot be dropped, because other objects are dependent on it.
42894 The DEFAULT value is invalid.
42895 For static SQL, an input host variable cannot be used, because its data type is not compatible with the parameter of a procedure or user-defined function.
428A0 An error occurred with the sourced function on which the user-defined function is based.
428A1 Unable to access a file referenced by a host file variable.
428A2 A table cannot be assigned to a multi-node node group, because it does not have a partition key.
428A3 An invalid path has been specified for an event monitor.
428A4 An invalid value has been specified for an event monitor option.
428A5 An exception table named in a SET INTEGRITY statement either does not have the proper structure, or it has been defined with generated columns, constraints, or triggers.
428A6 An exception table named in a SET INTEGRITY statement cannot be the same as one of the tables being checked.
428A7 There is a mismatch in the number of tables being checked and in the number of exception tables specified in the SET INTEGRITY statement.
428A8 Cannot reset the check-pending state using the SET INTEGRITY statement on a descendent table while a parent table is in the check-pending state.
428A9 The node range is invalid.
428AA The column name is not a valid column for an event monitor table.
428B0 Illegal nesting inside ROLLUP, CUBE, or GROUPING SETS.
428B1 Incorrect number of table space container specifications that are not designated for specific nodes.
428B2 The path name for the container is not valid.
428B3 An invalid SQLSTATE was specified.
428B7 A number specified in an SQL statement is out of the valid range.
428BO No plan was possible to create for the federated data source.
428C0 The node cannot be dropped, because it is the only node in the nodegroup.
428C1 Only one ROWID column can be specified for a table.
428C2 Examination of the function body indicates that the given clause should have been specified on the CREATE FUNCTION statement.
428C4 The number of elements on each side of the predicate operator is not the same.
428C5 No data type mapping was found for a data type from the data source.
428C9 A ROWID column cannot be specified as the target column of an INSERT or UPDATE.
428CA A table in append mode cannot have a clustered index.
428CB The page size for a table space must match the page size of the associated bufferpool.
428D1 Unable to access a file referenced by a DATALINK value.
428D4 A cursor specified in a FOR statement cannot be referenced in an OPEN, CLOSE, or FETCH statement.
428D5 The ending label does not match the beginning label.
428D6 UNDO is not allowed for NOT ATOMIC statements.
428D7 The condition value is not allowed.
428D8 The declaration or use of the SQLSTATE or SQLCODE variable is not valid.
428DB An object is not valid as a supertype, supertable, or superview.
428DC The function or method is not valid as the transform for this type.
428DD A required transform is not defined.
428DE PAGESIZE value is not supported.
428DF Data types specified in CREATE CAST are not valid.
428DG Function specified in CREATE CAST is not valid.
428DH Operation is not valid for typed tables.
428DJ Inherited column or attribute cannot be changed or dropped.
428DK The scope for the reference column is already defined.
428DL Parameter of external or sourced function has a scope defined.
428DM The scope table or view is not valid for the reference type.
428DN SCOPE is not specified in the RETURNS clause of an external function or is specified in the RETURNS clause of a sourced function.
428DP The type is not a structured type.
428DQ A subtable or subview cannot have a different schema name than its supertable or superview.
428DR Operation cannot be applied to a sub-table.
428DS Index on the specified columns cannot be defined on subtable.
428DT Operand of expression is not a valid scoped reference type.
428DU A type is not included in the required type hierarchy.
428DV Invalid left operand of a dereference operator.
428DW Object identifier column cannot be referenced using the dereference operator.
428DX Object identifier column is required to define the root table or root view of a typed table or typed view hierarchy.
428DY Statistics cannot be updated for the target object tpe.
428DZ An object identifier column cannot be updated.
428E0 Definition of index does not match the definition of the index extension.
428E1 Result of the range-producing table function is inconsistent with that of the key transformation table function for the index extension.
428E2 Number or the type of key-target parameters does not match with the number or type of key transform function for the index extension.
428E3 Argument for function in index extension is not valid.
428E4 Function is not supported in CREATE INDEX EXTENSION statement.
428E5 SELECTIVITY clause can only be specified with a user-defined predicate.
428E6 The search argument of method in the user-defined predicate does not match the one in the corresponding search method of the index extension.
428E7 Type of the operand following the comparison operator in the user-defined predicate does not match the RETURNS data type.
428E8 A search target or search argument parameter does not match a parameter name of the function being created.
428E9 An argument parameter name cannot appear as both a search target and search argument in the same exploitation rule.
428EA A fullselect in a typed view is not valid.
428EB A column in a subview cannot be read only when the corresponding column in the superview is updatable.
428EC The fullselect specified for the materialized query table is not valid.
428ED Structured types with Datalink or Reference type attributes cannot be constructed.
428EE Option is not valid for this data source.
428EF Value for the option is not valid for this data source.
428EG Missing required option for this data source.
428EH Cannot ADD an option that is already defined.
428EJ Cannot SET or DROP an option that has not been added.
428EK The qualifier for a declared global temporary table name must be SESSION.
428EL A transform function is not valid for use with a function or method.
428EM The TRANSFORM GROUP clause is required.
428EN A transform group is specified that is not used.
428EP A structured type cannot depend on itself either directly or indirectly.
428EQ The returns type of the routine is not the same as the subject type.
428ER A method specification cannot be dropped before the method body is dropped.
428ES A method body does not correspond to the language type of the method specification.
428EU TYPE or VERSION is not specified in the server definition.
428EV Pass-through facility is not supported for the type of data source.
428EW The table cannot be converted to or from a materialized query table.
428EX Routine cannot be used as a transform function because it is either a builtin function or a method.
428EY The data type of the search target in a user-defined predicate does not match the data type of the source key of the specified index extension.
428EZ A window specification for an OLAP function is not valid.
428F0 A ROW function must include at least two columns.
428F1 An SQL TABLE function must return a table result.
428F2 The data type of the RETURN statement value in an SQL procedure must be INTEGER.
428F3 SCROLL and WITH RETURN are mutually exclusive.
428F4 The SENSITIVITY specified on FETCH is not allowed for the cursor.
428F6 Cursor is scrollable, but the result table involves output from a table function.
428F7 An operation that applies only to SQL routines was attempted on an external routine.
428F9 A sequence expression cannot be specified in this context.
428FA The scale of the decimal number must be zero.
428FB The sequence-name must not be a sequence generated by the system for an identity column.
428FC The length of the encryption password is not valid.
428FD The password used for decryption does not match the password used to encrypt the data.
428FE The data is not a result of the ENCRYPT function.
428FF The buffer pool specification is not valid.
428FG The table used to define a staging table is not valid.
428FH The SET INTEGRITY option is not valid
428FI ORDER OF was specified, but the table-designator does not contain an ORDER BY clause.
428FJ ORDER BY is not allowed in the outer fullselect of a view or materialized query table.
428FL An SQL data change statement is not allowed in the context in which it was specified.
428FM An INSERT statement within a SELECT specified a view which is not a symmetric view.
428FP One INSTEAD OF trigger is allowed for each kind of operation on a subject view.
428FQ An INSTEAD OF trigger must not specify a view that is defined using WITH CHECK OPTION, a view that is defined on another view that is defined WITH CHECK OPTION, or a view that is nested in a view that is defined with the WITH ROW MOVEMENT clause.
428FU Built-in type returned from the FROM SQL transform function or method does not match the corresponding built-in type for the TO SQL transform function or method.
428FV Cannot define the method as an overriding method.
428FZ A view that has INSTEAD OF triggers defined only for some operations cannot be used as a target in the MERGE statement.
428G3 FINAL TABLE is not valid when the target view of the SQL data change statement in a fullselect has an INSTEAD OF trigger defined.
428G4 Invalid use of INPUT SEQUENCE ordering.
428G5 The assignment clause of the UPDATE statement must specify at least one column that is not an INCLUDE column.
428G6 A colum is specified that cannot be selected from the target of the data change statement in the FROM clause of the fullselect.
428G8 The view cannot be enabled for query optimization.
428GA Federated option cannot be added, dropped, or altered.
42901 A column function does not include a column name.
42903 A WHERE clause or SET clause includes an invalid reference, such as a column function.
42904 The SQL procedure was not created because of a compile error.
42907 The string is too long.
42908 The statement does not include a required column list.
42910 The statement is not allowed in a Compond statement.
42911 A decimal divide operation is invalid, because the result would have a negative scale.
42912 A column cannot be updated, because it is not identified in the UPDATE clause of the select-statement of the cursor.
42914 The DELETE is invalid, because a table referenced in a subquery can be affected by the operation.
42915 An invalid referential constraint has been detected.
42916 The alias cannot be created, because it would result in a repetitive chain of aliases.
42917 The object cannot be explicitly dropped or altered.
42918 A user-defined data type cannot be created with a system-defined data type name (for example, INTEGER).
42919 Nested compound statements are not allowed.
42921 Containers cannot be added to the tablespace.
42925 Recursive named derived tables cannot specify SELECT DISTINCT and must specify UNION ALL.
42928 WITH EMPTY TABLE cannot be specified for the table.
42932 The program preparation assumptions are incorrect.
42939 The name cannot be used because the specified identifier is reserved for system use.
42961 The server name specified does not match the current server.
42962 A long column, LOB column, or structured type column cannot be used in an index, a key, or a constraint.
42968 The connection failed, because there is no current software license.
42969 The package was not created.
42972 An expression in a join-condition or ON clause of a MERGE statement references columns in more than one of the operand tables.
42985 The statement is not allowed in a routine.
42987 The statement is not allowed in a procedure or trigger.
42989 A GENERATED column that is based on an expression cannot be used in a BEFORE trigger.
42991 The BOOLEAN data type is currently only supported internally.
42993 The column, as defined, is too large to be logged.
42994 Raw device containers are not supported.
42995 The requested function does not apply to global temporary tables.
42997 Capability is not supported by this version of the DB2 application requester, DB2 application server, or the combination of the two.
429A0 A foreign key cannot reference a parent table defined as not logged initially.
429A1 Nodegroup is not valid for the table space.
429A9 SQL statement cannot be processed by DataJoiner.
429B2 Specified inline length value for the structured type or column is too small.
429B3 Object may not be defined on a subtable.
429B4 Data filter function cannot be a LANGUAGE SQL function.
429B5 Data type of instance parameter in index extension is not valid.
429B8 A routine defined with PARAMETER STYLE JAVA cannot have a structured type as a parameter or returns type.
429B9 DEFAULT or NULL cannot be used in an attribute assignment.
429BA The FEDERATED keyword must be used with a reference to a federated database object.
429BB A data type specified for a parameter or variable is not supported in a SQL routine.
429BC There are multiple container actions in the ALTER TABLESPACE statement.
429BE The primary key or unique key is a subset of the columns in the dimensions clause.
429BG The function is not supported for range-clustered tables.
429BJ Invalid usage of WITH ROW MOVEMENT in a view.
429BK Invalid attempt to update a view because of because of row movement involving underlying views.
429BL A function which modifies SQL data is invoked in an illegal context.
429BO No plan was possible to create for the federated data source.
429BP Invalid nickname column expression.

Class Code 44 WITH CHECK OPTION Violation
Table 31. Class Code 44: WITH CHECK OPTION Violation SQLSTATE Value
Meaning
44000 The insert or update operation is not allowed, because a resulting row does not satisfy the view definition.

Class Code 46 Java DDL
Table 32. Class Code 46: Java DDL SQLSTATE Value
Meaning
46001 Java DDL - Invalid URL.
46002 Java DDL - Invalid jar name.
46003 Java DDL - Invalid class deletion.
46007 Java DDL - Invalid signature.
46008 Java DDL - Invalid method specification.
46103 A Java routine encountered a ClassNotFound exception.
46501 Java DDL - Optional component not implemented.

Class Code 51 Invalid Application State
Table 33. Class Code 51: Invalid Application State SQLSTATE Value
Meaning
51002 The package corresponding to an SQL statement execution request was not found.
51003 Consistency tokens do not match.
51004 An address in the SQLDA is invalid.
51005 Thr previous system error has disabled this function.
51008 The release number of the precompiled program is not valid.
51015 An attempt was made to execute a section that was found to be in error at bind time.
51017 The user is not logged on.
51021 SQL statements cannot be executed until the application process executes a rollback operation.
51022 A CONNECT that specifies an authorization name is invalid when a connection (either current or dormant) already exists to the server named in that CONNECT statement.
51023 The database is already in use by another instance of the database manager.
51024 A view cannot be used, because it has been marked inoperative.
51025 An application in the XA transaction processing environment is not bound with SYNCPOINT TWOPHASE.
51026 An event monitor cannot be turned on, because its target path is already in use by another event monitor.
51027 The IMMEDIATE CHECKED option of the SET INTEGRITY statement is not valid since a table is a user maintained materialized query table or is not in the check-pending state.
51028 A package cannot be used, because it is marked inoperative.
51030 The procedure referenced in a ALLOCATE CURSOR, or an ASSOCIATE LOCATORS statement has not yet been called within the application process.
51034 A routine defined with MODIFIES SQL DATA is not valid in the context in which it is invoked.
51035 A PREVVAL expression cannot be used because a value has not been generated for the sequence yet in this session.
51038 SQL statements may no longer be issued by the routine.
51039 The ENCRYPTION PASSWORD value is not set.
51040 Invalid compilation environment.

Class Code 53 Invalid Operand or Inconsistent Specification
Table 34. Class Code 53: Invalid Operand or Inconsistent Specification SQLSTATE Value
Meaning
53040 The specified buffer pool does not exist on the specified database partition.
53090 Only data from one encoding scheme, either ASCII, EBCDIC or Unicode, can be referenced in the same SQL statement.
53091 The encoding scheme specified is not the same as the encoding scheme currently in use for the containing object.

Class Code 54 SQL or Product Limit Exceeded
Table 35. Class Code 54: SQL or Product Limit Exceeded SQLSTATE Value
Meaning
54001 The statement is too long or too complex.
54002 A string constant is too long.
54004 The statement has too many table names or too many items in a SELECT or INSERT list.
54006 The result of concatenation is too long.
54008 The key is too long, has too many columns, or a key column is too long.
54010 The record length of the table is too long.
54011 Too many columns were specified for a table or view.
54023 The limit for the number of parameters or arguments for a function or a procedure has been exceeded.
54028 The maximum number of concurrent LOB handles has been reached.
54029 The maximum number of open directory scans has been reached.
54030 The maximum number of event monitors are already active.
54031 The maximum number of files have already been assigned the event monitor.
54032 The maximum size of a table has been reached.
54033 The maximum number of partitioning maps has been reached.
54034 The combined length of all container names for the tablespace is too long.
54035 An internal object limit exceeded.
54036 The path name for the container or storage path is too long.
54037 The container map for the tablespace is too complicated.
54038 Maximum depth of nested routines or triggers was exceed.
54045 Maximum levels of a type hierarchy exceeded.
54046 The maximum allowable parameters is exceeded in an index extension.
54047 The maximum size of a table space is exceeded.
54048 A temporary table space with sufficient page size does not exist.
54049 Length of an instance of a structured type exceeds system limit.
54050 The maximum allowable attributes is exceeded in a structured type.
54052 The number of block pages for a buffer pool is too large for the size of the buffer pool.
54053 The value specified for BLOCKSIZE is not in the valid range.

Class Code 55 Object Not in Prerequisite State
Table 36. Class Code 55: Object Not in Prerequisite State SQLSTATE Value
Meaning
55001 The database must be migrated.
55002 The explanation table is not defined properly.
55006 The object cannot be dropped, because it is currently in use by the same application process.
55007 The object cannot be altered, because it is currently in use by the same application process.
55009 The system attempted to write to a read-only file or a write-protected diskette.
55012 A clustering index already exists on the table.
55019 The table is in an invalid state for the operation.
55022 The file server is not registered with this database.
55023 An error occured calling a routine.
55024 The tablespace cannot be dropped, because data related to a table is also in another tablespace.
55025 The database must be restarted.
55026 A temporary tablespace cannot be dropped.
55031 The format of the error mapping file is incorrect.
55032 The CONNECT statement is invalid, because the database manager was stopped after this application was started.
55033 An event monitor cannot be activated in the same unit of work in which it is created or modified.
55034 The event monitor is in an invalid state for the operation.
55035 The table cannot be dropped, because it is protected.
55036 The node cannot be dropped, because it has not been removed from the partitioning map.
55037 The partitioning key cannot be dropped, because the table is in a multi-node nodegroup.
55038 The nodegroup cannot be used, because it is being rebalanced.
55039 The access or state transition is not allowed, because the tablespace is not in an appropriate state.
55041 Containers cannot be added to a tablespace while a rebalance is in progress.
55043 Attributes of a structured type cannot be altered when a typed table or typed view based on the type exists.
55045 The SQL Archive (SAR) file for the routine cannot be created because a necessary component is not available at the server.
55046 The specified SQL archive does not match the target environment.
55047 An external function or method attempted to access a federated object.
55048 Encrypted data cannot be encrypted.
55049 The event monitor table is not properly defined.
55051 The ALTER BUFFERPOOL statement is currently in progress.
55054 Cannot define the method as an overriding method.
55056 The nickname statistics cannot be updated because the database is not enabled for federation.
55060 Automatic storage has not been defined for the database.
55061 The redirected restore of an automatic storage table space is not allowed.
55062 Storage paths cannot be provided because the database is not enabled for automatic storage.

Class Code 56 Miscellaneous SQL or Product Error
Table 37. Class Code 56: Miscellaneous SQL or Product Error SQLSTATE Value
Meaning
56031 The clause or scalar function is invalid, because mixed and DBCS data are not supported on this system.
56033 The insert or update value of a long string column must be a host variable or NULL.
56038 The requested feature is not supported in this environment.
56072 Execution failed due to the function not supported by a downlevel server that will not affect the execution of subsequent SQL statements.
56084 LOB data is not supported in DRDA.
56091 Multiple errors occurred as a result of executing a compound SQL statement.
56092 The type of authorization cannot be determined, because the authorization name is both a user id and group id.
56095 A bind option is invalid.
56097 LONG VARCHAR and LONG VARGRAPHIC fields are not permitted in TABLESPACEs which are built on DEVICEs.
56098 An error occurred during implicit rebind or prepare.
56099 The REAL data type is not supported by the target database.
560A0 Action on a LOB value failed.
560AA The clause or scalar function is invalid, because UCS-2 is not supported on this system.
560AC Wrapper definition cannot be used for the specified type or version of data source.
560AF PREPARE statement is not supported when using gateway concentrator.
560B0 Invalid new size value for table space or table space container resizing.
560B1 Invalid cursor specification in stored procedure.
560B7 For a multiple row INSERT, the usage of a sequence expression must be the same for each row.
560BB For an INOUT parameter in a dynamically prepared CALL statement, the same host variable must be used in both the USING and INTO clauses.
560BC An error has occurred when accessing a file.
560BD A federated server received an unexpected error code from a data source.
560BF Encryption facility not available.
560C0 Tables created in the Unicode encoding scheme cannot be used in SQL functions or SQL methods.
560C1 Tables created in the Unicode encoding scheme cannot be a typed table, or contain graphic types or user-defined types.
560C2 Writing a history file entry for a dropped table failed.
560C3 An AFTER trigger cannot modify a row being inserted for an INSERT statement.
560C6 A referential constraint cannot modify a row that was modified by an SQL data change statement within a fullselect.
560C8 Some of the nickname statistics cannot be updated.
560C9 The specified statement cannot be explained.
560CA The SQL statement references a routine which can only be run on the current database partition.

Class Code 57 Resource Not Available or Operator Intervention
Table 38. Class Code 57: Resource Not Available or Operator Intervention SQLSTATE Value
Meaning
57001 The table is unavailable, because it does not have a primary index.
57003 The specified bufferpool has not been activated.
57007 The object cannot be used, because a DROP or ALTER is pending.
57009 Virtual storage or database resource is temporarily unavailable.
57011 Virtual storage or database resource is not available.
57012 A non-database resource is not available. This will not affect the successful execution of subsequent statements.
57013 A non-database resource is not available. This will affect the successful execution of subsequent statements.
57014 Processing was canceled as requested.
57016 The table cannot be accessed, because it is inactive.
57017 Character conversion is not defined.
57019 The statement was not successful, because of a problem with a resource.
57020 The drive containing the database is locked.
57021 The diskette drive door is open.
57022 The table could not be created, because the authorization ID of the statement does not own any suitable dbspaces.
57030 Connection to application server would exceed the installation-defined limit.
57032 The maximum number of concurrent databases have already been started.
57033 Deadlock or timeout occurred without automatic rollback.
57036 The transaction log does not belong to the current database.
57046 A new transaction cannot start because the database or instance is quiesced.
57047 An internal database file cannot be created, because the directory is not accessible.
57048 An error occurred while accessing a container for a tablespace.
57049 The operating system process limit has been reached.
57050 The file server is not currently available.
57051 The estimated CPU cost exceeds the resource limit.
57052 Node is unavailable, because it does not have containers for all temporary table spaces.
57053 The operation cannot be performed on the table because of conflicting operations.
57055 A temporary table space with sufficient page size was not available.
57056 Package is not available because the database is in NO PACKAGE LOCK mode.
57057 The SQL statement cannot be executed due to a prior condition in a DRDA chain of SQL statements.
57059 There is not enough space in the table space for the specified action.

Class Code 58 System Error
Table 39. Class Code 58: System Error SQLSTATE Value
Meaning
58004 A system error (that does not necessarily preclude the successful execution of subsequent SQL statements) occurred.
58005 A system error (that prevents the successful execution of subsequent SQL statements) occurred.
58008 Execution failed due to a distribution protocol error that will not affect the successful execution of subsequent DDM commands or SQL statements.
58009 Execution failed due to a distribution protocol error that caused deallocation of the conversation.
58010 Execution failed due to a distribution protocol error that will affect the successful execution of subsequent DDM commands or SQL statements.
58011 The DDM command is invalid while the bind process in progress.
58012 The bind process with the specified package name and consistency token is not active.
58014 The DDM command is not supported.
58015 The DDM object is not supported.
58016 The DDM parameter is not supported.
58017 The DDM parameter value is not supported.
58018 The DDM reply message is not supported.
58023 A system error has caused the current program to be canceled.
58030 An I/O error has occurred.
58031 The connection was unsuccessful, because of a system error.
58032 Unable to use the process for a fenced mode user-defined function.
58034 An error was detected while attempting to find pages for an object in a DMS tablespace.
58035 An error was detected while attempting to free pages for an object in a DMS tablespace.
58036 The internal tablespace ID specified does not exist.
ZZZZZ Placeholder sqlstate for development use only. Must be changed before code is shipped.

MySQL - Part 1 - Step by Step


Start - Stop - Restart MySQL Server on Linux 

sudo  /etc/init.d/mysqld  stop
sudo  /etc/init.d/mysqld  start
sudo  /etc/init.d/mysqld  restart




Start the MySql Database
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqld
Listing the Databases/schemas available using root user.

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root
+--------------------+
Databases
+--------------------+
information_schema
mysql
test
+--------------------+

Here three Databases/schemas are available as seen listed above.

Listing content of Schema test, by the command below.

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root test
Database: test
+--------+
Tables
+--------+
+--------+

Its not having any table.

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root information_schema
Database: information_schema
+---------------------------------------+
Tables
+---------------------------------------+
CHARACTER_SETS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
ENGINES
EVENTS
FILES
GLOBAL_STATUS
GLOBAL_VARIABLES
KEY_COLUMN_USAGE
PARTITIONS
PLUGINS
PROCESSLIST
PROFILING
REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
SESSION_STATUS
SESSION_VARIABLES
STATISTICS
TABLES
TABLE_CONSTRAINTS
TABLE_PRIVILEGES
TRIGGERS
USER_PRIVILEGES
VIEWS
+---------------------------------------+

A lot of tables are available in information_schema.

Selecting the status of MySql Database on your machine


C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqladmin version status proc
mysqladmin Ver 8.42 Distrib 5.1.31, for Win32 on ia32
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version 5.1.31-community
Protocol version 10
Connection localhost via TCP/IP
TCP port 3308
Uptime: 15 min 10 sec

Threads: 1 Questions: 31 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.34
Uptime: 910 Threads: 1 Questions: 31 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second
avg: 0.34
mysqladmin: process list failed; error: 'Access denied; you need the PROCESS privilege for this operation'

Using test database.

Open test database

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.1.31-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Create table shop in test database.

mysql> CREATE TABLE shop (
-> article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
-> dealer CHAR(20) DEFAULT '' NOT NULL,
-> price DOUBLE(16,2) DEFAULT '0.00' NOT NULL,
-> PRIMARY KEY(article, dealer));
Query OK, 0 rows affected (0.03 sec)

Insert records in shop table

mysql> INSERT INTO shop VALUES
-> (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
-> (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
Query OK, 7 rows affected (0.03 sec)
Records: 7 Duplicates: 0 Warnings: 0

Select records from shop table.

mysql> select * from shop;
+---------+--------+-------+
article dealer price
+---------+--------+-------+
0001 A 3.45
0001 B 3.99
0002 A 10.99
0003 B 1.45
0003 C 1.69
0003 D 1.25
0004 D 19.95
+---------+--------+-------+
7 rows in set (0.00 sec)

mysql>exit

Listing tables present in test database. The shop table created above.


C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow test
Database: test
+--------+
Tables
+--------+
shop
+--------+

Amazon Best Sellors

TOGAF 9.2 - STUDY [ The Open Group Architecture Framework ] - Chap 01 - Introduction

100 Feet View of TOGAF  What is Enterprise? Collection of Organization that has common set of Goals. Enterprise has People - organized by co...