apache / apache/incubator-seata
When getting the primary key index, jdbc will get a null pointer when it encounters oracle12c
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
- [ ] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.
### Ⅰ. Issue Description
1.获取主键索引时,jdbc在oracle12c上遇到会获取到空指针的情况下有可能是驱动问题影响的,所以换成了从数据库中查询,更改了TableMetaCacheOracle中resultSetMetaToSchema 方法获取主键索引修改为:
```
try (Statement stmt = conn.getTargetConnection().createStatement();
ResultSet rs1 = stmt.executeQuery(
String.format("select a.constraint_name, a.column_name from user_cons_columns a, user_constraints b " +
"where a.constraint_name = b.constraint_name and b.constraint_type = 'P' and a.table_name ='%s'",
tableName))) {
while (rs1.next()) {
String indexName = rs1.getString(1);
String colName = rs1.getString(2);
ColumnMeta col = tm.getAllColumns().get(colName);
if (tm.getAllIndexes().containsKey(indexName)) {
IndexMeta index = tm.getAllIndexes().get(indexName);
index.getValues().add(col);
} else {
IndexMeta index = new IndexMeta();
index.setIndexName(indexName);
index.getValues().add(col);
index.setIndextype(IndexType.PRIMARY);
tm.getAllIndexes().put(indexName, index);
}
}
}
```
### Ⅱ. Describe what happened
If there is an exception, please attach the exception trace:
```
Just paste your stack trace here!
```
### Ⅲ. Describe what you expected to happen
### Ⅳ. How to reproduce it (as minimally and precisely as possible)
1. xxx
2. xxx
3. xxx
### Ⅴ. Anything else we need to know?
### Ⅵ. Environment:
- JDK version : jdk 8
- OS : docker
- Others: ojdbc8-18.3.00
Contributor guide
Research direction
Start at TableMetaCacheOracle.resultSetMetaToSchema and inspect how primary-key indexes are obtained for Oracle 12c. Reproduce with JDK 8, Docker, and ojdbc8-18.3.00, using the SQL query shown in the issue as the reference. Done means primary-key metadata is populated without a null-pointer exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100