SQLCODE -808: CONNECT not consistent with the first CONNECT
SQLCODE -808 (SQLSTATE 08001) means a program issued a CONNECT of one type after the application process had already used the other type. The first CONNECT a process runs fixes whether it follows type 1 or type 2 rules, and every later CONNECT has to match.
Other names for this code
Also written as SQL -808, SQLCODE=-808, SQLCODE = -808, db2 -808, SQL0808N, connect statement is not consistent with the first connect statement, CONNECT(1) CONNECT(2).
What it means
Db2 has two sets of rules for the CONNECT statement. With type 1, a process works with one server at a time. With type 2, a process can hold connections to several servers, switch between them with SET CONNECTION, and update more than one of them in a unit of work when two-phase commit is available.
Which rules a CONNECT follows is decided when the program is prepared, by the CONNECT precompiler option. CONNECT(2) is the default. At run time, the first CONNECT the application process executes sets the rules for the whole process. If a later CONNECT was prepared with the other option, Db2 rejects it with -808.
So -808 isn't about the server or the network. It means two programs in the same process were prepared differently.
Common causes
- A main program and a called subprogram were precompiled with different CONNECT options, for example one with an explicit CONNECT(1) and the other with the default.
- An old program prepared years ago with CONNECT(1) is now called from new code that uses the default type 2.
- A shared connection routine was changed and prepared again with a different option from the programs that call it.
How to find the problem
- Note which CONNECT failed, then work back to the first CONNECT the process ran. It may be in a different program in the call chain.
- Check the precompile or coprocessor options for every program involved. The listing prints the options in effect near the top, and your build or change tool may record them too.
- Look for CONNECT(1) in the build procedures, JCL or project settings. Since type 2 is the default, the program with an explicit CONNECT(1) is usually the odd one out.
How to fix it
- Prepare every program in the application with the same CONNECT option. Using the default type 2 everywhere is the simplest choice.
- After you precompile again, bind the new DBRMs into their packages and promote the load modules with them, so the package and module stay in step.
- If the application relies on type 1 behavior, keep it type 1 everywhere instead, and make sure no new module brings in type 2.
- Resubmit the job once all programs match.
What it looks like
DSNT408I SQLCODE = -808, ERROR: THE CONNECT STATEMENT IS NOT CONSISTENT WITH THE FIRST
CONNECT STATEMENT
DSNT418I SQLSTATE = 08001 SQLSTATE RETURN CODEIBM documentation
IBM documentation: -808. Use the documentation for your installed release.
Related codes
Questions
Which CONNECT type is the default?
Type 2. A program gets type 1 rules only if it was prepared with CONNECT(1).
Is -808 a network or server problem?
No. It comes from how the programs in the process were prepared, so checking the server, the network or the location name won't help. Look at the precompile options instead.
Is SQL0808N on Db2 for LUW the same error?
It's the same idea with the same SQLSTATE 08001. On Db2 for LUW the message says the CONNECT came from a source file prepared with different connection options, such as the CONNECT type or SQLRULES, than a file that already has a connection. If the files can't all be prepared the same way, the SET CLIENT API can set the options before the first CONNECT.