public static String javaNameToDbName(String javaName){
  if (javaName == null)   return null;
  if (javaName.length() <= 0)   return "";
  StringBuilder dbName=new StringBuilder();
  dbName.append(Character.toUpperCase(javaName.charAt(0)));
  int namePos=1;
  while (namePos < javaName.length()) {
    char curChar=javaName.charAt(namePos);
    if (Character.isUpperCase(curChar))     dbName.append('_');
    dbName.append(Character.toUpperCase(curChar));
    namePos++;
  }
  return dbName.toString();
}

public static String javaNameToDbName ( String javaName ) { if ( javaName == null ) return null ; if ( javaName . length ( ) <= 0 ) return "" ; StringBuilder dbName = new StringBuilder ( ) ; dbName . append ( Character . toUpperCase ( javaName . charAt ( 0 ) ) ) ; int namePos = 1 ; while ( namePos < javaName . length ( ) ) { char curChar = javaName . charAt ( namePos ) ; if ( Character . isUpperCase ( curChar ) ) dbName . append ( '_' ) ; dbName . append ( Character . toUpperCase ( curChar ) ) ; namePos ++ ; } return dbName . toString ( ) ; }
converts a java variable name to a database name . the naming conventions used to allow for this are as follows : a database name ( table or column ) is in all capital letters , and the words are separated by an underscore ( for example : neat_entity_name or random_field_name ) ; a java name ( ejb or field ) is in all lower case letters , except the letter at the beginning of each word ( for example : neatentityname or randomfieldname ) . the convention of using a capital letter at the beginning of a class name in java , or a lower - case letter for the beginning of a variable name in java is also used along with the java name convention above .
