3

I use dbslim for (Selenium) Fitnesse: https://github.com/markfink/dbslim

I'd like to connect to a SQL Server 2014.

How should my jdbc line be formatted?

Not like so:

| script | Db Slim Setup |!-oracle.jdbc.driver.OracleDriver-!| jdbc:oracle:thin:@host_name:1521:database_name | username | password |

but how else?

p.s. the file is called DbSlimSetup.java

The DbSlimSetup looks like this by the way:

/*******************************************************************************
* The MIT License
* 
* Copyright (c) 2010, Mark S.
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package slim;

import services.DbConnectionFactory;

public class DbSlimSetup {

    public static String DEFAULT_CONNECTION_POOL_NAME = "default";
    public static int DEFAULT_CONNECTION_POOL_MIN_IDLE = 1;
    public static int DEFAULT_CONNECTION_POOL_MAX_AXTIVE = 5;
    public static int DEFAULT_WAIT_TIMEOUT = 45000;


    public DbSlimSetup(
        String jdbcDriverClass,
        String connectURI, String username, String password) throws Exception {

    DbConnectionFactory.getDataSource(
            DEFAULT_CONNECTION_POOL_NAME,
            jdbcDriverClass,
            connectURI, username, password,
            DEFAULT_CONNECTION_POOL_MIN_IDLE, DEFAULT_CONNECTION_POOL_MAX_AXTIVE);
}

public DbSlimSetup(
        String jdbcDriverClass,
        String connectURI, String username, String password,
        int minIdle, int maxActive) throws Exception{

    DbConnectionFactory.getDataSource(
            DEFAULT_CONNECTION_POOL_NAME,
            jdbcDriverClass,
            connectURI, username, password,
            minIdle, maxActive);

}

public DbSlimSetup(
        String jdbcDriverClass,
        String connectionPoolName,
        String connectURI, String username, String password,
        int minIdle, int maxActive) throws Exception {

    DbConnectionFactory.getDataSource(
            connectionPoolName,
            jdbcDriverClass,
            connectURI, username, password,
            minIdle, maxActive);
}
}

So how can it be called with 'Db Slim Setup' there are spaces, i don't understand that part. can someone explain?

Please help I'm new to this.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
tijnn
  • 406
  • 1
  • 8
  • 24

3 Answers3

1

Try this

!path C:\Xebium\target\classes

|import|
|slim|

!define host_name {########}

| script | Db Slim Setup |!-oracle.jdbc.driver.OracleDriver-!| jdbc:oracle:thin:${host_name}:1521:database_name | username | password |

Note that, you cannot use this in a Scenario (if thats what you are trying to do by using '@'), because this is calling the constructor of the fixture class, and supposed to be an isolated table.

Xiawei Zhang
  • 1,690
  • 1
  • 11
  • 24
  • If it helps with your problem, I would appreciate that you accept it as answer. – Xiawei Zhang Dec 10 '15 at 09:02
  • yes that is going to help, but i have a different problem now.... I builded the .class files on a VM, then I transported the .class files to another VM in the same directory. but now the message is: java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/ComboPooledDataSource where can i find this: com/mchange/v2/c3p0/ComboPooledDataSource – tijnn Dec 17 '15 at 11:41
  • the pom.xml file needed the dependency. "then the c3p0.jar needed to be found when running StartXebium.bat" – tijnn Dec 17 '15 at 12:31
0

Sorry guys, this time your help so far didn't work.

The correct answer should have been something like:

a) first you'll have to build correctly. so download dbslim copy the c3p0-0.9.12.jar to the directory c:\Xebium\src\main\java\slim

b) then when it builds the class files you're ready to go further.

c) now use the path! command to add the target directory (that part you where right) so:

!path C:\Xebium\target\classes\services

!path C:\Xebium\target\classes\slim

after this, the message could not invoke is gone!!! YEAY...

but now I have another problem :( which is:

EXCEPTION:java.lang.NoClassDefFoundError: DbSlimSetup (wrong name: slim/DbSlimSetup) at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_51] at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_51] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.8.0_51] at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) [rt.jar:1.8.0_51] at java.net.URLClassLoader.access$100(URLClassLoader.java:73) [rt.jar:1.8.0_51] at java.net.URLClassLoader$1.run(URLClassLoader.java:368) [rt.jar:1.8.0_51] at java.net.URLClassLoader$1.run(URLClassLoader.java:362) [rt.jar:1.8.0_51] at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_51] at java.net.URLClassLoader.findClass(URLClassLoader.java:361) [rt.jar:1.8.0_51] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [rt.jar:1.8.0_51] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) [rt.jar:1.8.0_51] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [rt.jar:1.8.0_51] at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_51] at java.lang.Class.forName(Class.java:264) [rt.jar:1.8.0_51] at fitnesse.slim.fixtureInteraction.DefaultInteraction.getClass(DefaultInteraction.java:57) [fitnesse-20150814.jar] at fitnesse.slim.fixtureInteraction.DefaultInteraction.searchPathsForClass(DefaultInteraction.java:40) [fitnesse-20150814.jar] at fitnesse.slim.fixtureInteraction.DefaultInteraction.createInstance(DefaultInteraction.java:20) [fitnesse-20150814.jar] at fitnesse.slim.SlimExecutionContext.create(SlimExecutionContext.java:48) [fitnesse-20150814.jar] at fitnesse.slim.StatementExecutor.create(StatementExecutor.java:80) [fitnesse-20150814.jar] at fitnesse.slim.instructions.MakeInstruction.executeInternal(MakeInstruction.java:26) [fitnesse-20150814.jar] at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29) [fitnesse-20150814.jar] at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49) [fitnesse-20150814.jar] at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43) [fitnesse-20150814.jar] at fitnesse.slim.ListExecutor.execute(ListExecutor.java:83) [fitnesse-20150814.jar] at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:87) [fitnesse-20150814.jar] at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:80) [fitnesse-20150814.jar] at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:58) [fitnesse-20150814.jar] at fitnesse.slim.SlimServer.serve(SlimServer.java:43) [fitnesse-20150814.jar] at fitnesse.slim.SlimService.handle(SlimService.java:186) [fitnesse-20150814.jar] at fitnesse.slim.SlimService.acceptOne(SlimService.java:194) [fitnesse-20150814.jar] at fitnesse.slim.SlimService.accept(SlimService.java:156) [fitnesse-20150814.jar] at fitnesse.slim.SlimService.startWithFactory(SlimService.java:77) [fitnesse-20150814.jar] at fitnesse.slim.SlimService.main(SlimService.java:57) [fitnesse-20150814.jar]

tijnn
  • 406
  • 1
  • 8
  • 24
0

solution: example connection to sql database with Fitnesse via DbSlim is:

| script | !-Db Slim Setup-! |!-com.mysql.jdbc.Driver-!| jdbc:mysql://172.55.55.55:3306/AdventureWorks2012 | testlab | secretpassword |

tijnn
  • 406
  • 1
  • 8
  • 24