D'abord la classe InterbaseManager
puis MissionDatabaseManager
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 package com.all4tec.matelo.linguistique.wizards; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Connection; import java.util.Properties; import java.sql.SQLPermission; public class InterbaseManager { static Connection connection; static Statement stmt; static Connection ConnectServer( String wsLogin, String wsPassword, String wsDatabaseFullPathName) throws SQLException { long ErrorCode = 0; if( ErrorCode == 0) { // Provider=SQLNCLI11;User Instance=true;MARS Connection=true;AttachDbFilename=C:\\Programmes\\Microsoft SQLServer\\MSSQL10_50.SQLEXPRESS\\MSSQL\\DATA\\Coherence.mdf;Driver={SQL Server Native Client 11.0};Initial Catalog=Northwind try { // Chargement du pilote JDBC //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver" ).newInstance(); //"Integrated Security=true;Pooling=true;Max Pool Size=100;Timeout=15;MultipleActiveResultSets=true;Type System Version=SQL Server 2014;database=COHERENCE;server=xantia\\SQLEXPRESS" Properties props = new Properties(); props.setProperty( "Initial Catalog", "Northwind"); props.setProperty( "Auto Reconnect", "true"); props.setProperty( "AttachDbFilename", "C:\\Programmes\\Microsoft SQL Server\\MSSQL12.SQLEXPRESS\\MSSQL\\DATA\\Coherence.mdf"); props.setProperty( "Type System Version", "SQL Server 2014"); props.setProperty( "Pooling", "true"); props.setProperty( "MaxPoolSize", "100"); props.setProperty( "MultipleActiveResultSets", "true"); props.setProperty( "Timeout", "15"); //props.setProperty( "Driver", "Microsoft SQL Server Express Edition (64-bit)"); //props.setProperty( "Driver Version", "12.0.2000 RTM"); props.setProperty( "databaseName", "Coherence"); props.setProperty( "integratedSecurity", "true"); props.setProperty( "instance","Xantia\\SQLEXPRESS"); props.setProperty( "user","XANTIA\\JeanNoël"); // URL de connexion String url = "jdbc:odbc:login_DSN"; connection = DriverManager.getConnection( url, props); stmt = connection.createStatement(); Data.m_bServerConnected = true; } catch( SQLException ex) { ex.printStackTrace(); Data.m_bServerConnected = false; } finally { } } return( connection); //OD } static ResultSet ExecuteSelectRequest( String wsRequest) throws SQLException { int iNbResultFound = 0; String Result; String stream; boolean Status; // IF myConnection" is not NULL) THEN if( stmt == null) { connection = ConnectServer( "", "", ""); stmt = connection.createStatement(); } // try { stmt.execute( wsRequest); } catch( SQLException ex) { ex.printStackTrace(); Status = false; } return( stmt.getResultSet()); } }
enfin la console
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 package com.all4tec.matelo.linguistique.wizards; import java.sql.Connection; import java.sql.ResultSet; import java.sql.DriverManager; import java.sql.ResultSetMetaData; import java.sql.SQLData; import java.sql.SQLException; import java.sql.SQLInput; import java.sql.Statement; import java.util.ArrayList; import org.eclipse.emf.edit.command.SetCommand; public class MissionDatabaseManager { public static class stUnivers { int idParagraph; String wsName; stUnivers() { } } public static Connection connect; private static String wssRequest; private static SetCommand dataSource; public int i = 0; static boolean returnValue; private static boolean bIsConnected; public int iSize; static SQLData myReader; static Connection connection = null; static Statement stmt = null; public static Connection OpenDatabaseCoherence() throws SQLException, ClassNotFoundException, IllegalArgumentException, NullPointerException { try { bIsConnected = false; connection = InterbaseManager.ConnectServer( "", "", ""); bIsConnected = true; } catch( IllegalArgumentException e) { // this occurs when the driver is wrongly configured in Eclipse e.printStackTrace(); } catch( NullPointerException e) { // this occurs when no server engine is started e.printStackTrace(); } if( connection != null ) { returnValue = true; } else { returnValue = false; } return( connection); } static Structure.ElementWork WorkElement; static ArrayList<Structure.ElementWork> ReadWork() throws SQLException { ArrayList<Structure.ElementWork> pListText; int iNbResultFound; pListText = new ArrayList<Structure.ElementWork>(); String cmd = "SELECT iIdDoc, vcDocument FROM T_WORK_INFORMATION WHERE siIdStateDocument = 3"; ResultSet resultset = InterbaseManager.ExecuteSelectRequest( cmd); ResultSetMetaData rsmd = resultset.getMetaData(); iNbResultFound = 0; try { while( resultset.next()) { iNbResultFound++; WorkElement = new Structure.ElementWork(); WorkElement.wsText = resultset.getString( "vcDocument"); if(java.sql.Types.INTEGER == rsmd.getColumnType(1)) { WorkElement.Id = resultset.getInt( "iIdDoc"); } pListText.add( WorkElement); } } catch( SQLException ex) { ex.printStackTrace(); } return( pListText); } static String getUnivers(int indice, int iIdDoc) throws SQLException { String wsUnivers = ""; int iNbResultFound = 0; String cmd = "SELECT EL.vcName FROM T_ELEMENT_LINKS EL WHERE EL.nuIdParagraph = " + indice + " AND EL.iIdDoc = " + iIdDoc; ResultSet resultset = InterbaseManager.ExecuteSelectRequest( cmd); while( resultset.next()) { wsUnivers = resultset.getString( 1); iNbResultFound ++; } return( wsUnivers); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 !SESSION 2015-04-30 07:22:13.714 ----------------------------------------------- eclipse.buildId=unknown java.version=1.7.0_71 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR Framework arguments: -product com.all4tec.matelo.ui.product Command-line arguments: -product com.all4tec.matelo.ui.product -data D:\usr\MTL v5.2 Release/../runtime-MaTeLo -dev file:D:/usr/MTL v5.2 Release/.metadata/.plugins/org.eclipse.pde.core/MaTeLo/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -data @noDefault !ENTRY org.eclipse.equinox.registry 2 0 2015-04-30 07:22:23.160 !MESSAGE The extensions and extension-points from the bundle "org.eclipse.emf.validation.source" are ignored. The bundle is not marked as singleton. !ENTRY org.eclipse.osgi 2 0 2015-04-30 07:22:24.049 !MESSAGE One or more bundles are not resolved because the following root constraints are not resolved: !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.049 !MESSAGE Bundle update@plugins/org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar was not resolved. !SUBENTRY 2 org.eclipse.swt.gtk.linux.x86_64 2 0 2015-04-30 07:22:24.049 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.049 !MESSAGE Bundle update@plugins/org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar was not resolved. !SUBENTRY 2 org.eclipse.swt.gtk.linux.x86 2 0 2015-04-30 07:22:24.049 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.049 !MESSAGE Bundle update@plugins/org.eclipse.swt.win32.win32.x86_3.8.1.v3836b.jar was not resolved. !SUBENTRY 2 org.eclipse.swt.win32.win32.x86 2 0 2015-04-30 07:22:24.049 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !ENTRY org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists: !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.core.filesystem.linux.x86_1.4.0.v20120522-1137 [24] was not resolved. !SUBENTRY 2 org.eclipse.core.filesystem.linux.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.os=linux) (osgi.arch=x86)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b [91] was not resolved. !SUBENTRY 2 org.eclipse.swt.gtk.linux.x86_64 2 0 2015-04-30 07:22:24.065 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b [136] was not resolved. !SUBENTRY 2 org.eclipse.swt.gtk.linux.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.core.filesystem.win32.x86_1.1.300.v20120522-1137 [137] was not resolved. !SUBENTRY 2 org.eclipse.core.filesystem.win32.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.os=win32) (osgi.arch=x86)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807 [149] was not resolved. !SUBENTRY 2 org.eclipse.equinox.launcher.win32.win32.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807 [164] was not resolved. !SUBENTRY 2 org.eclipse.equinox.launcher.gtk.linux.x86_64 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=x86_64)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.core.filesystem.linux.x86_64_1.2.0.v20120522-1137 [222] was not resolved. !SUBENTRY 2 org.eclipse.core.filesystem.linux.x86_64 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.os=linux) (osgi.arch=x86_64)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.equinox.security.win32.x86_1.0.300.v20120522-2049 [224] was not resolved. !SUBENTRY 2 org.eclipse.equinox.security.win32.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.os=win32) (osgi.arch=x86)) !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.swt.win32.win32.x86_3.8.1.v3836b [298] was not resolved. !SUBENTRY 2 org.eclipse.swt.win32.win32.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.0))(&(osgi.ee=JavaSE)(version=1.3)))". !SUBENTRY 1 org.eclipse.osgi 2 0 2015-04-30 07:22:24.065 !MESSAGE Bundle org.eclipse.equinox.launcher.gtk.linux.x86_1.1.200.v20120913-144807 [299] was not resolved. !SUBENTRY 2 org.eclipse.equinox.launcher.gtk.linux.x86 2 0 2015-04-30 07:22:24.065 !MESSAGE Platform filter did not match: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=x86)) !ENTRY com.all4tec.matelo.ui 1 1 2015-04-30 07:22:24.236 !MESSAGE MaTeLo v5.2 (Curie) ${product.suffix_version} (Build ${env.BUILD_NUMBER}${compilation.suffix}) started on 04-30-2015 07:22:24 !ENTRY org.eclipse.core.resources 2 10035 2015-04-30 07:22:25.568 !MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. !ENTRY com.all4tec.matelo.utils 1 1 2015-04-30 07:22:33.365 !MESSAGE Instances chains tree validated !ENTRY com.all4tec.matelo.utils 1 1 2015-04-30 07:22:33.457 !MESSAGE Project 'Test' opened java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Index de descripteur non valide at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source) at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source) at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source) at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source) at com.all4tec.matelo.linguistique.wizards.MissionDatabaseManager.ReadWork(MissionDatabaseManager.java:87) at com.all4tec.matelo.linguistique.wizards.LinguistiqueImportWizard.RecupereNomDesFichier(LinguistiqueImportWizard.java:61) at com.all4tec.matelo.linguistique.wizards.LinguistiqueImportWizard$1.run(LinguistiqueImportWizard.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Partager