Datasource SpringJDBC数据源连接集类型映射

Datasource SpringJDBC数据源连接集类型映射,datasource,spring-jdbc,Datasource,Spring Jdbc,您好,我想将mytypemappings设置为connection,但无法更改数据源类型映射。setType映射无效 DataSource javax.sql DriverManager数据源数据源=新的DriverManager数据源(ConnectionStringInfo); Map此时mymap不可见 每次调用dataSource.getConnection()都会得到一个新的Connection实例,因此需要将类型映射添加到每个新实例中。什么不起作用?有错误吗?期望值是什么?没有错误,

您好,我想将mytypemappings设置为connection,但无法更改数据源类型映射。setType映射无效

DataSource javax.sql

DriverManager数据源数据源=新的DriverManager数据源(ConnectionStringInfo);
Map此时mymap不可见

每次调用
dataSource.getConnection()
都会得到一个新的
Connection
实例,因此需要将类型映射添加到每个新实例中。

什么不起作用?有错误吗?期望值是什么?没有错误,但当我再次像dataSource.getConnection().getTypeMap()这样进行查询时,我上次添加的映射在此列表中没有看到。请共享完整的代码。我添加了示例,谢谢
     Map map = dataSource.getConnection().getTypeMap();
    map.put("mytpe", myclass);
   connection = dataSource.getConnection();
    connection.setTypeMap(map);//(connection set and when I get I see type map)
   dataSource.getConnection().setTypeMap(map);//(connection set and when I get I cant see type map)
     DriverManagerDataSource dataSource = new DriverManagerDataSource(connectionstringinfos);

        Map<String,Class<Object> map2= dataSource.getConnection().getTypeMap();
        map2.put("mymap",MyMap.class);
        dataSource.getConnection().setTypeMap(map2);
dataSource.getConnection().getTypeMap();-->that time mymap does not seen