rcp如何连接数据库

本文探讨了在SWT环境下成功运行的数据库连接代码,在迁移到RCP环境中时遇到的问题及错误提示。作者尝试了使用特定的数据库连接器,并在SWT测试环境中验证了其可行性,但在RCP环境中却出现了无法创建视图的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 我做了一个测试在swt和java中是正确的但当放入rcp中调用出现错误提示!!!

连接器

import java.sql.Connection;

public class ConnectionDB {

 public ConnectionDB(){}
 public ConnectionDB(String driver,String dburl,String userName,String password){
 }

 public Connection getConnection(){
  // Declare the JDBC objects.
  Connection con = null;
  try {
   // Establish the connection.
   com.microsoft.sqlserver.jdbc.SQLServerDataSource ds = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
   ds.setIntegratedSecurity(true);
   ds.setServerName("localhost");
   ds.setPortNumber(1433);
   ds.setDatabaseName("binya");
   ds.setUser("sa");
   ds.setPassword("3110154576");
   con = ds.getConnection();
  } catch (Exception e){
   e.printStackTrace();
  }
  return con;
 }
}

java、swt测试:

import java.sql.*;

import com.hy.archive.db.ConnectionDB;

public class ConnectTest {

 public static void main(String[] args) {

  // Declare the JDBC objects.
  Connection con = new ConnectionDB().getConnection();
  try{
   System.out.println("ok");
   con.close();
  }catch(Exception e){
   e.printStackTrace();
  }
 }
}

测试正确

放入rcp出现如下错误:

    try {
     UIStats.start(UIStats.CREATE_PART_CONTROL, label);
     view.createPartControl(content);

     parent.layout(true);
    } finally {
     UIStats.end(UIStats.CREATE_PART_CONTROL, view, label);  -----------
    }

无法创建视图:com/microsoft/sqlserver/jdbc/SQLServerDataSource

 

什么原因呢?

Use of NWAI-WG data   So far, NWAI-WG data have been used on a collaborative basis in publications (see the attached file). The major reasons are the data were not widely distributed. They were only used in our group and our collaborative networks. There were some cases with requests of the data made after people read Liu and Zou's (2012) paper. You have two options for using the data. Option 1: Collaboration with us. In this case, we will help you to describe the downscaling method and contribute to other parts of the paper such as comments/suggestions on the papers, if the fields are within our expertise. Option 2: Use of the data on your own. While option 1 for collaboration with us is welcome, option 2 is also highly encouraged, particularly, when the data are used for these research disciplines, rather than agricultural related. Thanks to Professor Yu who provides us with his group's web site (www.agrivy.com) as a media for distribution of the data.   Acknowledgment for option 1  “We acknowledge the modelling groups, the Program for Climate Model Diagnosis and Intercomparison (PCMDI) and the WCRP’s Working Group on Coupled Modelling (WGCM) for their roles in making available the WCRP CMIP5 multi-model dataset. Support of this dataset is provided by the Office of Science, US Department of Energy. Dr. Ian Macadam of the University of New South Wales downloaded the raw GCM monthly data. ”   Acknowledgment for option 2  “We acknowledge the modelling groups, the Program for Climate Model Diagnosis and Intercomparison (PCMDI) and the WCRP’s Working Group on Coupled Modelling (WGCM) for their roles in making available the WCRP CMIP5 multi-model dataset. Support of this dataset is provided by the Office of Science, US Department of Energy. Dr. Ian Macadam of the University of New South Wales downloaded the raw GCM monthly data. Dr. De Li Liu of the NSW Department of Primary Industries used NWAI-WG to downscale downscaled daily data. Also, thanks to AGRIVY (www.agrivy.com) provides us the data for this study.”
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值