Revision 1338

View differences:

trunk/libraries/libGDBMS/src/com/hardcode/gdbms/engine/data/FileDataSourceAdapter.java
16 16
    private File file;
17 17
    private FileDriver driver;
18 18

  
19
    private int sem = 0;
20
    
19 21
    /**
20 22
     * @see com.hardcode.gdbms.engine.data.DataSource#start()
21 23
     */
22 24
    public void start() throws DriverException {
23 25
        try {
26
        	if (sem == 0)
24 27
            driver.open(file);
28
        	
29
        	sem++;
25 30
        } catch (IOException e) {
26 31
            throw new DriverException(e);
27 32
        }
......
32 37
     */
33 38
    public void stop() throws DriverException {
34 39
        try {
40
        	sem--;
35 41
        	System.out.println("Numero de accesos: " + accesos);
42
        	if (sem == 0)
36 43
            driver.close();
37 44
        } catch (IOException e) {
38 45
            throw new DriverException(e);
trunk/libraries/libGDBMS/src/com/hardcode/gdbms/engine/data/DBDataSourceAdapter.java
18 18
	private String password;
19 19
	private DBDriver driver;
20 20

  
21
	private int sem = 0;
22
	
21 23
    /**
22 24
     * @see com.hardcode.gdbms.engine.data.DataSource#start()
23 25
     */
24 26
    public void start() throws DriverException {
25 27
        try {
28
        	if (sem == 0)
26 29
            driver.connect(host, port, dbName, user, password);
30
        	
31
        	sem++;
27 32
        } catch (SQLException e) {
28 33
            throw new DriverException(e);
29 34
        }
......
34 39
     */
35 40
    public void stop() throws DriverException {
36 41
        try {
37
            driver.closeTable();
38
            driver.closeConnection();
42
        	sem--;
43
        	
44
        	if (sem == 0){
45
		        driver.closeTable();
46
		        driver.closeConnection();
47
        	}
39 48
        } catch (SQLException e) {
40 49
            throw new DriverException(e);
41 50
        }

Also available in: Unified diff