Here you can find the source of adjustIdentifierCase(String identifier, Connection conn)
Parameter | Description |
---|---|
identifier | a SQL identifier. |
conn | a JDBC connection |
Parameter | Description |
---|---|
SQLException | an exception |
public static String adjustIdentifierCase(String identifier, Connection conn) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; public class Main { /**// w ww.j ava2 s. c o m * Adjusts an SQL identifier to correct case according to the database convention. * * @param identifier a SQL identifier. * @param conn a JDBC connection * @return case-adjusted identifier * @throws SQLException */ public static String adjustIdentifierCase(String identifier, Connection conn) throws SQLException { DatabaseMetaData md = conn.getMetaData(); if (!md.storesMixedCaseIdentifiers() && identifier != null) { if (md.storesUpperCaseIdentifiers()) { return identifier.toUpperCase(); } if (md.storesLowerCaseIdentifiers()) { return identifier.toLowerCase(); } } return identifier; } }