当前位置:   article > 正文

PostgreSQL与Java JDBC数据类型对照 源码_postgresql jdbc 源码

postgresql jdbc 源码

 文件:postgresql-42.2.12.jar
类名:org.postgresql.jdbc.TypeInfoCache

  1. // basic pg types info:
  2. // 0 - type name
  3. // 1 - type oid
  4. // 2 - sql type
  5. // 3 - java class
  6. // 4 - array type oid
  7. private static final Object[][] types = {
  8. {"int2", Oid.INT2, Types.SMALLINT, "java.lang.Integer", Oid.INT2_ARRAY},
  9. {"int4", Oid.INT4, Types.INTEGER, "java.lang.Integer", Oid.INT4_ARRAY},
  10. {"oid", Oid.OID, Types.BIGINT, "java.lang.Long", Oid.OID_ARRAY},
  11. {"int8", Oid.INT8, Types.BIGINT, "java.lang.Long", Oid.INT8_ARRAY},
  12. {"money", Oid.MONEY, Types.DOUBLE, "java.lang.Double", Oid.MONEY_ARRAY},
  13. {"numeric", Oid.NUMERIC, Types.NUMERIC, "java.math.BigDecimal", Oid.NUMERIC_ARRAY},
  14. {"float4", Oid.FLOAT4, Types.REAL, "java.lang.Float", Oid.FLOAT4_ARRAY},
  15. {"float8", Oid.FLOAT8, Types.DOUBLE, "java.lang.Double", Oid.FLOAT8_ARRAY},
  16. {"char", Oid.CHAR, Types.CHAR, "java.lang.String", Oid.CHAR_ARRAY},
  17. {"bpchar", Oid.BPCHAR, Types.CHAR, "java.lang.String", Oid.BPCHAR_ARRAY},
  18. {"varchar", Oid.VARCHAR, Types.VARCHAR, "java.lang.String", Oid.VARCHAR_ARRAY},
  19. {"text", Oid.TEXT, Types.VARCHAR, "java.lang.String", Oid.TEXT_ARRAY},
  20. {"name", Oid.NAME, Types.VARCHAR, "java.lang.String", Oid.NAME_ARRAY},
  21. {"bytea", Oid.BYTEA, Types.BINARY, "[B", Oid.BYTEA_ARRAY},
  22. {"bool", Oid.BOOL, Types.BIT, "java.lang.Boolean", Oid.BOOL_ARRAY},
  23. {"bit", Oid.BIT, Types.BIT, "java.lang.Boolean", Oid.BIT_ARRAY},
  24. {"date", Oid.DATE, Types.DATE, "java.sql.Date", Oid.DATE_ARRAY},
  25. {"time", Oid.TIME, Types.TIME, "java.sql.Time", Oid.TIME_ARRAY},
  26. {"timetz", Oid.TIMETZ, Types.TIME, "java.sql.Time", Oid.TIMETZ_ARRAY},
  27. {"timestamp", Oid.TIMESTAMP, Types.TIMESTAMP, "java.sql.Timestamp", Oid.TIMESTAMP_ARRAY},
  28. {"timestamptz", Oid.TIMESTAMPTZ, Types.TIMESTAMP, "java.sql.Timestamp",
  29. Oid.TIMESTAMPTZ_ARRAY},
  30. //JCP! if mvn.project.property.postgresql.jdbc.spec >= "JDBC4.2"
  31. {"refcursor", Oid.REF_CURSOR, Types.REF_CURSOR, "java.sql.ResultSet", Oid.REF_CURSOR_ARRAY},
  32. //JCP! endif
  33. {"json", Oid.JSON, Types.OTHER, "org.postgresql.util.PGobject", Oid.JSON_ARRAY},
  34. {"point", Oid.POINT, Types.OTHER, "org.postgresql.geometric.PGpoint", Oid.POINT_ARRAY}
  35. };
  36. /**
  37. * PG maps several alias to real type names. When we do queries against pg_catalog, we must use
  38. * the real type, not an alias, so use this mapping.
  39. */
  40. private static final HashMap<String, String> typeAliases;
  41. static {
  42. typeAliases = new HashMap<String, String>();
  43. typeAliases.put("smallint", "int2");
  44. typeAliases.put("integer", "int4");
  45. typeAliases.put("int", "int4");
  46. typeAliases.put("bigint", "int8");
  47. typeAliases.put("float", "float8");
  48. typeAliases.put("boolean", "bool");
  49. typeAliases.put("decimal", "numeric");
  50. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/510064?site
推荐阅读
相关标签
  

闽ICP备14008679号