Java Code Examples for java.sql.DatabaseMetaData#importedKeySetNull()
The following examples show how to use
java.sql.DatabaseMetaData#importedKeySetNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataTest.java From r-course with MIT License | 6 votes |
private static String cascadeOptionToString(int option) { switch (option) { case DatabaseMetaData.importedKeyCascade: return "CASCADE"; case DatabaseMetaData.importedKeySetNull: return "SET NULL"; case DatabaseMetaData.importedKeyRestrict: return "RESTRICT"; case DatabaseMetaData.importedKeyNoAction: return "NO ACTION"; } return "SET DEFAULT"; }
Example 2
Source File: MetadataTest.java From Komondor with GNU General Public License v3.0 | 6 votes |
private static String cascadeOptionToString(int option) { switch (option) { case DatabaseMetaData.importedKeyCascade: return "CASCADE"; case DatabaseMetaData.importedKeySetNull: return "SET NULL"; case DatabaseMetaData.importedKeyRestrict: return "RESTRICT"; case DatabaseMetaData.importedKeyNoAction: return "NO ACTION"; } return "SET DEFAULT"; }
Example 3
Source File: JdbcModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Converts the JDBC action value (one of the <code>importKey</code> constants in the * {@link DatabaseMetaData} class) to a {@link CascadeActionEnum}. * * @param jdbcActionValue The jdbc action value * @return The enum value */ protected CascadeActionEnum convertAction(Short jdbcActionValue) { CascadeActionEnum action = null; if (jdbcActionValue != null) { switch (jdbcActionValue.shortValue()) { case DatabaseMetaData.importedKeyCascade: action = CascadeActionEnum.CASCADE; break; case DatabaseMetaData.importedKeySetNull: action = CascadeActionEnum.SET_NULL; break; case DatabaseMetaData.importedKeySetDefault: action = CascadeActionEnum.SET_DEFAULT; break; case DatabaseMetaData.importedKeyRestrict: action = CascadeActionEnum.RESTRICT; break; } } return action; }
Example 4
Source File: MetadataTest.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
private static String cascadeOptionToString(int option) { switch (option) { case DatabaseMetaData.importedKeyCascade: return "CASCADE"; case DatabaseMetaData.importedKeySetNull: return "SET NULL"; case DatabaseMetaData.importedKeyRestrict: return "RESTRICT"; case DatabaseMetaData.importedKeyNoAction: return "NO ACTION"; } return "SET DEFAULT"; }
Example 5
Source File: JdbcModelReader.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Converts the JDBC action value (one of the <code>importKey</code> constants in the * {@link DatabaseMetaData} class) to a {@link CascadeActionEnum}. * * @param jdbcActionValue The jdbc action value * @return The enum value */ protected CascadeActionEnum convertAction(Short jdbcActionValue) { CascadeActionEnum action = null; if (jdbcActionValue != null) { switch (jdbcActionValue.shortValue()) { case DatabaseMetaData.importedKeyCascade: action = CascadeActionEnum.CASCADE; break; case DatabaseMetaData.importedKeySetNull: action = CascadeActionEnum.SET_NULL; break; case DatabaseMetaData.importedKeySetDefault: action = CascadeActionEnum.SET_DEFAULT; break; case DatabaseMetaData.importedKeyRestrict: action = CascadeActionEnum.RESTRICT; break; } } return action; }
Example 6
Source File: JDBCReverseEngineeringStrategy.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 5 votes |
/** * Convert a JDBC Cascade Type to the Mogwai CascadeType. * <p/> * Default is CASCADE. * * @param aValue the JDBC type * @return the CascadeType */ protected CascadeType getCascadeType(int aValue) { switch (aValue) { case DatabaseMetaData.importedKeyNoAction: return CascadeType.NOTHING; case DatabaseMetaData.importedKeySetNull: return CascadeType.SETNULL; case DatabaseMetaData.importedKeyCascade: return CascadeType.CASCADE; case DatabaseMetaData.importedKeyRestrict: return CascadeType.RESTRICT; default: return CascadeType.CASCADE; } }
Example 7
Source File: DatabaseMetaDataTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Test referential action values; modifies database * @throws SQLException */ public void testReferentialAction() throws SQLException { Statement s = createStatement(); getConnection().setAutoCommit(false); // First, create the test table and indexes/keys // note: apparently we have no test for setdefault. s.execute("create table refaction1(a int not null primary key)"); s.execute("create table refactnone(a int references refaction1(a))"); s.execute("create table refactrestrict(a int references refaction1(a) on delete restrict)"); s.execute("create table refactnoaction(a int references refaction1(a) on delete no action)"); s.execute("create table refactcascade(a int references refaction1(a) on delete cascade)"); s.execute("create table refactsetnull(a int references refaction1(a) on delete set null)"); s.execute("create table refactupdrestrict(a int references refaction1(a) on update restrict)"); s.execute("create table refactupdnoaction(a int references refaction1(a) on update no action)"); short restrict = DatabaseMetaData.importedKeyRestrict; short no_action = DatabaseMetaData.importedKeyNoAction; short cascade = DatabaseMetaData.importedKeyCascade; short setnull = DatabaseMetaData.importedKeySetNull; short setdefault = DatabaseMetaData.importedKeySetDefault; ResultSet rs[] = getCrossReference("","APP","REFACTION1","","APP","REFACTNONE"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTRESTRICT"); verifyReferentialAction(rs, new short[] {no_action, restrict}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTCASCADE"); verifyReferentialAction(rs, new short[] {no_action, cascade}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTSETNULL"); verifyReferentialAction(rs, new short[] {no_action, setnull}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTUPDRESTRICT"); verifyReferentialAction(rs, new short[] {restrict, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTUPDNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTNONE"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTRESTRICT"); verifyReferentialAction(rs, new short[] {restrict, restrict}); rs = getImportedKeys(null, "APP", "REFACTNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTCASCADE"); verifyReferentialAction(rs, new short[] {no_action, cascade}); rs = getImportedKeys(null, "APP", "REFACTSETNULL"); verifyReferentialAction(rs, new short[] {no_action, setnull}); rs = getImportedKeys(null, "APP", "REFACTUPDRESTRICT"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTUPDNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getExportedKeys(null, "APP", "REFACTION1"); short [][] expkeyresults = { {no_action, cascade}, {no_action, no_action}, {no_action, no_action}, {no_action, restrict}, {no_action, setnull}, {no_action, no_action}, {restrict, no_action}}; for (int i = 0 ; i < 6 ; i++) { rs[0].next(); assertEquals(expkeyresults[i][0], rs[0].getShort(10)); assertEquals(expkeyresults[i][1], rs[0].getShort(11)); } for (int i = 0 ; i < 6 ; i++) { rs[1].next(); assertEquals(expkeyresults[i][0], rs[1].getShort(10)); assertEquals(expkeyresults[i][1], rs[1].getShort(11)); } s.execute("drop table refactnone"); s.execute("drop table refactupdrestrict"); s.execute("drop table refactupdnoaction"); s.execute("drop table refactrestrict"); s.execute("drop table refactnoaction"); s.execute("drop table refactcascade"); s.execute("drop table refactsetnull"); s.execute("drop table refaction1"); commit(); rs[0].close(); rs[1].close(); s.close(); getConnection().setAutoCommit(true); }
Example 8
Source File: DatabaseMetaDataTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Test referential action values; modifies database * @throws SQLException */ public void testReferentialAction() throws SQLException { Statement s = createStatement(); getConnection().setAutoCommit(false); // First, create the test table and indexes/keys // note: apparently we have no test for setdefault. s.execute("create table refaction1(a int not null primary key)"); s.execute("create table refactnone(a int references refaction1(a))"); s.execute("create table refactrestrict(a int references refaction1(a) on delete restrict)"); s.execute("create table refactnoaction(a int references refaction1(a) on delete no action)"); s.execute("create table refactcascade(a int references refaction1(a) on delete cascade)"); s.execute("create table refactsetnull(a int references refaction1(a) on delete set null)"); s.execute("create table refactupdrestrict(a int references refaction1(a) on update restrict)"); s.execute("create table refactupdnoaction(a int references refaction1(a) on update no action)"); short restrict = DatabaseMetaData.importedKeyRestrict; short no_action = DatabaseMetaData.importedKeyNoAction; short cascade = DatabaseMetaData.importedKeyCascade; short setnull = DatabaseMetaData.importedKeySetNull; short setdefault = DatabaseMetaData.importedKeySetDefault; ResultSet rs[] = getCrossReference("","APP","REFACTION1","","APP","REFACTNONE"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTRESTRICT"); verifyReferentialAction(rs, new short[] {no_action, restrict}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTCASCADE"); verifyReferentialAction(rs, new short[] {no_action, cascade}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTSETNULL"); verifyReferentialAction(rs, new short[] {no_action, setnull}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTUPDRESTRICT"); verifyReferentialAction(rs, new short[] {restrict, no_action}); rs = getCrossReference("","APP","REFACTION1","","APP","REFACTUPDNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTNONE"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTRESTRICT"); verifyReferentialAction(rs, new short[] {restrict, restrict}); rs = getImportedKeys(null, "APP", "REFACTNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTCASCADE"); verifyReferentialAction(rs, new short[] {no_action, cascade}); rs = getImportedKeys(null, "APP", "REFACTSETNULL"); verifyReferentialAction(rs, new short[] {no_action, setnull}); rs = getImportedKeys(null, "APP", "REFACTUPDRESTRICT"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getImportedKeys(null, "APP", "REFACTUPDNOACTION"); verifyReferentialAction(rs, new short[] {no_action, no_action}); rs = getExportedKeys(null, "APP", "REFACTION1"); short [][] expkeyresults = { {no_action, cascade}, {no_action, no_action}, {no_action, no_action}, {no_action, restrict}, {no_action, setnull}, {no_action, no_action}, {restrict, no_action}}; for (int i = 0 ; i < 6 ; i++) { rs[0].next(); assertEquals(expkeyresults[i][0], rs[0].getShort(10)); assertEquals(expkeyresults[i][1], rs[0].getShort(11)); } for (int i = 0 ; i < 6 ; i++) { rs[1].next(); assertEquals(expkeyresults[i][0], rs[1].getShort(10)); assertEquals(expkeyresults[i][1], rs[1].getShort(11)); } s.execute("drop table refactnone"); s.execute("drop table refactupdrestrict"); s.execute("drop table refactupdnoaction"); s.execute("drop table refactrestrict"); s.execute("drop table refactnoaction"); s.execute("drop table refactcascade"); s.execute("drop table refactsetnull"); s.execute("drop table refaction1"); commit(); rs[0].close(); rs[1].close(); s.close(); getConnection().setAutoCommit(true); }