使用产品:supermap iobjects JAVA 9D 操作系统:win10
数据类型:sqlserver2012
问题描述:我想打开已有的数据源,但是运行示例程序中的代码后,提示如下:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: connectionInfo
数据源别名已被占用
at com.supermap.data.Datasources.open(Unknown Source)
at colorchange_v1.CreateandOpenDataset$2.windowOpened(CreateandOpenDataset.java:96)
at java.awt.AWTEventMulticaster.windowOpened(Unknown Source)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
connectinfo用于连接工作空间,代码如下:
workspace = new Workspace();
WorkspaceConnectionInfo connectionInfo = new WorkspaceConnectionInfo();
connectionInfo.setDriver("SQL SERVER");
connectionInfo.setType(WorkspaceType.SQL);
connectionInfo.setServer("localhost");
connectionInfo.setDatabase("xjtsupermap_workplace");
connectionInfo.setUser("sa");
connectionInfo.setPassword("12345");
connectionInfo.setName("testworkplace");
connectionInfo.setVersion(WorkspaceVersion.UGC60);
boolean result = workspace.open(connectionInfo);
加了如下代码之后发生了错误:
DatasourceConnectionInfo datasourceconnection = new DatasourceConnectionInfo();
datasourceconnection.setEngineType(EngineType.SQLPLUS);
datasourceconnection.setServer("localhost");
datasourceconnection.setDatabase("xjtsupermap_datasource");
datasourceconnection.setUser("sa");
datasourceconnection.setPassword("12345");
datasourceconnection.setAlias("SQL");
datasourceconnection.setDriver("SQL Server");
datasource = workspace.getDatasources().open(datasourceconnection);
if (datasource == null) {
JOptionPane.showMessageDialog(null, "打开数据源失败.", "警告",JOptionPane.ERROR_MESSAGE);
datasourceconnection.dispose();
} else {
JOptionPane.showMessageDialog(null, "打开数据源成功");
datasourceconnection.dispose();
}
别名是什么意思?怎么解决这个问题呢啊?