package jdbc;

import java.sql.Types;

public enum SQLType {
	INTEGER{

		@Override
		public int typeCode() {
			return Types.INTEGER;
		}}, 
	BOOLEAN{

		@Override
		public int typeCode() {
			return Types.BOOLEAN;
		}},
	CHAR{

		@Override
		public int typeCode() {
			return Types.CHAR;
		}},
	VARCHAR{

		@Override
		public int typeCode() {
			return Types.VARCHAR;
		}},
	TIME{

		@Override
		public int typeCode() {
			return Types.TIME;
		}},
	DATE{

		@Override
		public int typeCode() {
			return Types.DATE;
		}},

	UNKNOWN{

		@Override
		public int typeCode() {
			return 100;
		}};

		abstract public int typeCode();
		static public SQLType getTypeFromCode(int i){
			switch(i){
			case Types.INTEGER : return INTEGER;
			case Types.BOOLEAN : return BOOLEAN;
			case Types.VARCHAR : return VARCHAR;
			case Types.TIME : return TIME;
			case Types.DATE : return DATE;
			default : return UNKNOWN; 
			}
		}
}

