|
| 1 | +packageorg.postgresql.core; |
| 2 | + |
| 3 | +importorg.postgresql.PG_Stream; |
| 4 | +importjava.io.IOException; |
| 5 | + |
| 6 | +/** |
| 7 | + * Sent to the backend to initialize a newly created connection. |
| 8 | + * |
| 9 | + * $Id: StartupPacket.java,v 1.1 2002/03/21 02:40:03 davec Exp $ |
| 10 | + */ |
| 11 | + |
| 12 | +publicclassStartupPacket |
| 13 | +{ |
| 14 | +privatestaticfinalintSM_DATABASE =64; |
| 15 | +privatestaticfinalintSM_USER =32; |
| 16 | +privatestaticfinalintSM_OPTIONS =64; |
| 17 | +privatestaticfinalintSM_UNUSED =64; |
| 18 | +privatestaticfinalintSM_TTY =64; |
| 19 | + |
| 20 | +privateintprotocolMajor; |
| 21 | +privateintprotocolMinor; |
| 22 | +privateStringuser; |
| 23 | +privateStringdatabase; |
| 24 | + |
| 25 | +publicStartupPacket(intprotocolMajor,intprotocolMinor,Stringuser,Stringdatabase) { |
| 26 | +this.protocolMajor =protocolMajor; |
| 27 | +this.protocolMinor =protocolMinor; |
| 28 | +this.user =user; |
| 29 | +this.database =database; |
| 30 | +} |
| 31 | + |
| 32 | +publicvoidwriteTo(PG_Streamstream)throwsIOException |
| 33 | + { |
| 34 | +stream.SendInteger(4 +4 +SM_DATABASE +SM_USER +SM_OPTIONS +SM_UNUSED +SM_TTY,4); |
| 35 | +stream.SendInteger(protocolMajor,2); |
| 36 | +stream.SendInteger(protocolMinor,2); |
| 37 | +stream.Send(database.getBytes(),SM_DATABASE); |
| 38 | + |
| 39 | +// This last send includes the unused fields |
| 40 | +stream.Send(user.getBytes(),SM_USER +SM_OPTIONS +SM_UNUSED +SM_TTY); |
| 41 | +} |
| 42 | +} |
| 43 | + |