如何在两个表之间建立连接但限制为满足连接条件的第一行?
在这个简单的例子中,我想为table_A中的每一行获取满足条件的table_B中的第一行:
select table_A.id, table_A.name, table_B.city
from table_A join table_B
on table_A.id = table_B.id2
where ..
table_A (id, name)
1, John
2, Marc
table_B (id2, city)
1, New York
1, Toronto
2, Boston
The output would be:
1, John, New York
2, Marc, Boston
Run Code Online (Sandbox Code Playgroud)
可能是Oracle提供了这样一个功能(性能是一个值得关注的问题).
我在尝试连接数据库时遇到了以下异常:
java.sql.SQLException: ORA-01005: null password given; logon denied
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:385)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:938)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:480)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:416)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:825)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:596)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at java.sql.DriverManager.getConnection(DriverManager.java:675)
at java.sql.DriverManager.getConnection(DriverManager.java:258)
at com.alting.db.ManagerDB.getConnection(ManagerDB.java:57)
at com.alting.db.ManagerDB.openConnection(ManagerDB.java:75)
at com.alting.med.EventGenerator.exportData(EventGenerator.java:220)
at com.alting.med.Main.main(Main.java:252)
Run Code Online (Sandbox Code Playgroud)
这里用于获取连接的方法:
private Connection getConnection(String url, String driverClass, String user, String password) throws ManagerDBException
{
try
{
Class.forName(driverClass);
} catch (ClassNotFoundException e) {
throw new ManagerDBException(e.getMessage());
}
try
{
this.connection = DriverManager.getConnection(url, user, …Run Code Online (Sandbox Code Playgroud) 我知道我们可以这样做:
<session-config>
<cookie-config>
<secure>true</secure>
</cookie-config>
</session-config>
Run Code Online (Sandbox Code Playgroud)
但我想要实现的是根据某些配置设置此标志(true或false).
我们应该使用过滤器吗?
谢谢