2014-09-20 51 views
-2

我正尝试在使用oracle数据库存储信息的Java中创建应用程序。我使用Eclipse并将数据库连接到Eclipse。我现在可以在Data Source Explorer中看到数据库连接。现在我该如何在我的应用程序中的数据库中使用表格?你能提供一个指导教程的链接吗?将数据库连接到Eclipse

+0

Google“JDBC教程” – hardillb 2014-09-20 17:42:18

+0

欢迎来到Stack Overflow!但是,要求我们推荐或查找教程或其他场外资源的问题是堆栈溢出的主题。 – honk 2014-09-20 18:17:03

回答

0

Data Tools Platform usage

首先例子,你犯了一个连接:

public java.sql.Connection getJavaConnectionForProfile (IConnectionProfile profile) { 
    IManagedConnection managedConnection = ((IConnectionProfile)profile). 
     getManagedConnection ("java.sql.Connection"); 
    if (managedConnection != null) { 
     return (java.sql.Connection) managedConnection.getConnection().getRawConnection(); 
    } 
    return null; 
    } 

这段代码,当然接入连接:

IConnectionProfile profile = ProfileManager.getInstance().getProfileByName("myprofile"); 
    IStatus status = profile.connect(); 
    if (status.getCode() == IStatus.OK)) { 
    // success 
    } else { 
    // failure :(
    if (status.getException() != null) { 
     status.getException().printStackTrace(); 
    } 
    } 

然后,使用管理池中获取JDBC连接存储在基于Eclipse的应用程序中的配置文件,并且不会在IDE中看到定义的内容。确保你不会混淆你的IDE和应用程序。