Can't Execute Query in MSSQL using JDBC in XPages - sql-server

I am using a JDBC Microsoft SQL driver in an xpage to get data from MS SQL server
The driver is installed using an update site and it is loaded successfully into the OSGI
I have also added a sqlserver.jdbc containing credentials to the webcontent\webinf\jdbc folder in the application
When I try to access the sql tables using #JdbcDbColumn it is working fine
var con=#JdbcGetConnection("sqlserver");
#JdbcDbColumn(con,"PrTr","Descr")
But when I try to execute a query like this
var con=#JdbcGetConnection("sqlserver");
var query="SELECT * FROM PrTr";
var rs=#JdbcExecuteQuery(con,query);
....
I get a stack trace error (on line 3) with lots of error lines, the lines that stand out are these
com.ibm.jscript.InterpretException: Script interpreter error, line=4,
col=8: Error while executing function '#JdbcExecuteQuery'
java.lang.ArrayIndexOutOfBoundsException
I have also tried to connect a view panel to a JDBCQuery data source but then I only get a 500 error wihtout a stacktrace
The SQL server is not on the same windows server as the xpages
in the stacktrace/tracelog there was one line that looked like this
java.security.AccessController.doPrivileged(AccessController.java:362)
But not sure if it is an error or only informational and if it is related to the query. i.e if there is a security problem.
I need help to understand why I can do the #JDBCDbColumn but not the #JDBCExecuteQuery
btw I just checked the SQLLog and do not see any entries related to my queries
Here is the full stacktrace
com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing
JavaScript computed expression
com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:132)
javax.faces.component.UIOutput.getValue(UIOutput.java:159)
com.ibm.xsp.util.FacesUtil.convertValue(FacesUtil.java:1122)
com.ibm.xsp.renderkit.html_basic.OutputTextRenderer.encodeEnd(OutputTextRenderer.java:97)
com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeEnd(ReadOnlyAdapterRenderer.java:180)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:1005)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:858)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:651)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:321)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:336)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:270)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:261)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
com.ibm.jscript.InterpretException: Script interpreter error, line=3,
col=10: Error while executing function '#JdbcExecuteQuery'
com.ibm.xsp.extlib.javascript.JdbcFunctions$NotesFunction.call(JdbcFunctions.java:389)
com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
java.security.AccessController.doPrivileged(AccessController.java:362)
com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:194)
com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78)
javax.faces.component.UIOutput.getValue(UIOutput.java:159)
com.ibm.xsp.util.FacesUtil.convertValue(FacesUtil.java:1122)
com.ibm.xsp.renderkit.html_basic.OutputTextRenderer.encodeEnd(OutputTextRenderer.java:97)
com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeEnd(ReadOnlyAdapterRenderer.java:180)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:1005)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:858)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:651)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:321)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:336)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:270)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:261)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2
com.ibm.jscript.types.FBSValueVector.get(FBSValueVector.java:76)
com.ibm.xsp.extlib.javascript.JdbcFunctions$NotesFunction.call(JdbcFunctions.java:267)
com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
java.security.AccessController.doPrivileged(AccessController.java:362)
com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:194)
com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78)
javax.faces.component.UIOutput.getValue(UIOutput.java:159)
com.ibm.xsp.util.FacesUtil.convertValue(FacesUtil.java:1122)
com.ibm.xsp.renderkit.html_basic.OutputTextRenderer.encodeEnd(OutputTextRenderer.java:97)
com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeEnd(ReadOnlyAdapterRenderer.java:180)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:1005)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:858)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:853)
com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:651)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:321)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:336)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:270)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:261)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)

I came across this problem some time ago with column names being upper cased for a method in Extension Library code -> How to get XPages and JSON to not put variable names in Uppercase
I'm not sure if it's the same problem, but may be worth investigating.

To find out if it's a security issue you could allow all permissions to Java. Create a java.pol file in the jvm/lib/ext/ folder, and add this:
grant {
permission java.security.AllPermission;
};
(don't forget to restart the server when you're done)
I've done custom JDBC connections by including the correct driver Jar file to the database and I needed to do this to get it work.

Related

While running gatling test getting following error "java.lang.IllegalArgumentException: requirement failed: CSV headers can't be empty"

I am creating a gatling script and trying to parameterize it. I have checked the path of CSV it is correct and CSV is present in the path mentioned in the configuration file. While running the gatling test from local machine getting below error and the test fails.
java.lang.IllegalArgumentException: requirement failed: CSV headers can't be empty
at scala.Predef$.require(Predef.scala:337)
at io.gatling.core.feeder.SeparatedValuesParser$.$anonfun$stream$5(SeparatedValuesParser.scala:47)
at io.gatling.core.feeder.SeparatedValuesParser$.$anonfun$stream$5$adapted(SeparatedValuesParser.scala:46)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
at io.gatling.core.feeder.SeparatedValuesParser$.$anonfun$stream$1(SeparatedValuesParser.scala:46)
at io.gatling.core.feeder.SeparatedValuesFeederSource.$anonfun$feeder$1(FeederSource.scala:118)
at scala.util.Using$.resource(Using.scala:261)
at io.gatling.core.feeder.SeparatedValuesFeederSource.applyBatch$1(FeederSource.scala:117)
at io.gatling.core.feeder.SeparatedValuesFeederSource.feeder(FeederSource.scala:125)
at io.gatling.core.feeder.SourceFeederBuilder.apply(FeederBuilder.scala:81)
at io.gatling.core.feeder.SourceFeederBuilder.apply(FeederBuilder.scala:50)
at io.gatling.core.action.builder.FeedBuilder.newFeedActor(FeedBuilder.scala:38)
at io.gatling.core.action.builder.FeedBuilder.$anonfun$build$1(FeedBuilder.scala:43)
at scala.collection.mutable.MapOps.getOrElseUpdate(Map.scala:146)
at scala.collection.mutable.MapOps.getOrElseUpdate$(Map.scala:143)
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:265)
at io.gatling.core.action.builder.FeedBuilder.build(FeedBuilder.scala:43)
at io.gatling.core.structure.BuildAction.$anonfun$build$1(BuildAction.scala:28)
at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
at scala.collection.immutable.List.foldLeft(List.scala:79)
at io.gatling.core.structure.BuildAction.build(BuildAction.scala:27)
at io.gatling.core.structure.BuildAction.build$(BuildAction.scala:26)
at io.gatling.core.structure.ScenarioBuilder.build(StructureBuilder.scala:51)
at io.gatling.core.structure.PopulationBuilder.build(PopulationBuilder.scala:100)
at io.gatling.core.scenario.SimulationParams.buildScenario(Simulation.scala:170)
at io.gatling.core.scenario.SimulationParams.$anonfun$scenarios$1(Simulation.scala:174)
at scala.collection.immutable.List.map(List.scala:246)
at io.gatling.core.scenario.SimulationParams.scenarios(Simulation.scala:174)
at io.gatling.app.Runner.run0(Runner.scala:79)
at io.gatling.app.Runner.run(Runner.scala:49)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromMap(Gatling.scala:40)
at Engine$.delayedEndpoint$Engine$1(Engine.scala:11)
at Engine$delayedInit$body.apply(Engine.scala:4)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1(App.scala:76)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterable.foreach(Iterable.scala:919)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at Engine$.main(Engine.scala:4)
at Engine.main(Engine.scala)
Not sure why test is failing any suggestion would be helpful.
Got the solution. I was referring to the csv and for one of the column the header name was not defined.
After removing the value without header name in csv file the test ran successfully.

Akeneo 2.2.5: No JobInstance found with code "add_to_existing_product_model"

Since the forum at akeneo.com is locked down, I posted my question here.
When I try to add Produkts to a Product-Model via mass-edit, I get the following error message:
No JobInstance found with code "add_to_existing_product_model"
[2018-06-19 19:39:31] request.INFO: Matched route "pim_enrich_mass_edit_rest_launch". {"route":"pim_enrich_mass_edit_rest_launch","route_parameters":{"_controller":"pim_enrich.controller.rest.mass_edit:launchAction","_route":"pim_enrich_mass_edit_rest_launch"},"request_uri":"http://pim.eu-trading.eu/rest/mass_edit/","method":"POST"} []
[2018-06-19 19:39:32] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Translation\Exception\NotFoundResourceException: "No JobInstance found with code "add_to_existing_product_model"" at ./vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/MassEditAction/OperationJobLauncher.php line 59 {"exception":"[object] (Symfony\\Component\\Translation\\Exception\\NotFoundResourceException(code: 0): No JobInstance found with code \"add_to_existing_product_model\" at ./vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/MassEditAction/OperationJobLauncher.php:59)"} []
I get this error with the latest version of Akeneo 2 (v2.2.5). The product model was created manually, the products to be associated with the model came through the api.
This error looks like a missing job in the database. Did you run all the doctrine migrations?
To do so you need to launch this command:
bin/console doctrine:migrations:migrate --env=prod
If you already launched the migrations and they failed, you can install a clean 2.2.5 PIM elsewhere and dump the job instance table to be able to add the missing jobs. Here is the list of the jobs to add or update in 2.2:
- add_association
- move_to_category
- add_to_category
- remove_from_category
- add_to_existing_product_model
- compute_family_variant_structure_changes
- compute_completeness_of_products_family
- add_attribute_value
- delete_products_and_product_models

Symfony 3.3 Doctrine Fixtures Load skipping SQL views

I'm trying to use SQL views with Doctrine.
Everything works fine so far, but I have a problem when running a basic fixtures load (with no options). I get the following error messages.
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'DELETE FROM gp_items':
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]View or function 'gp_items' is not updatable
because the modification affects multiple base tables.
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]View or function 'gp_items' is not updatable
because the modification affects multiple base tables.
[PDOException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]View or function 'gp_items' is not updatable
because the modification affects multiple base tables.
I looked at the code that loads the fixtures from the bundle ("doctrine/doctrine-fixtures-bundle": "^2.3") and I think I have to alter something to the ORMPurger (Doctrine\Common\DataFixtures\Purger) but I'm not sure how to go about that.
So I would like to know how to override a function in that specific class.
Cheers!
Ok,
So I decided to fork the DoctrineFixturesBundle and use my own version of it in my project.
https://github.com/jbonnier/DoctrineFixturesBundle
In order for composer to use it, I modified my composer.json file adding the following code before the last closing bracket.
,
"repositories": [
{
"type": "vcs",
"url": "https://github.com/jbonnier/DoctrineFixturesBundle"
}
]
I also change my require-dev statement to use my personnal branch.
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "dev-jbonnier",
...
}
EDIT:
Additional explanation.
I'm currently working with version v2.4.1 of the bundle.
Here's the change I made to it.
File : Command/LoadDataFixturesDoctrineCommand.php
Changed line 113
from
$purger = new ORMPurger($em);
to
$purger = new ORMPurger($em, $this->listViews($input->getOption('em')));
Add function to class after line 136
/**
* Return an array with all views names in the database.
*
* #return array
*/
protected function listViews($entityManager)
{
$em = $this->getContainer()->get('doctrine')->getManager($entityManager);
$conn = $em->getConnection();
$sm = $conn->getSchemaManager();
$views = $sm->listViews();
$rst = array();
foreach ($views as $view)
{
array_push($rst, $view->getName());
}
return $rst;
}
I had a similar problem. I was lazy so I did the workaround to load our fixtures this way.
I you find a clean solution I'm interested
bin/console -e=test doctrine:database:drop --if-exists --force
bin/console -e=test doctrine:database:create --if-not-exists --no-interaction
bin/console -e=test doctrine:migrations:migrate --no-interaction
bin/console -e=test doctrine:fixtures:load --append --no-interaction

Play Slick config

I'm trying to get started with play and slick.
Strategy; take hello-slick-3.1 project from the activator tutorials.
If works fine with the H2 in memory database. I want to connect to a sql server. After a battle I have some configuration which appear to connect using jdts.
In application .conf
driver=net.sourceforge.jtds.jdbc.Driver
url="jdbc:jtds:sqlserver://%%%%:1433;databaseName=%%%%;user=%%%;password=%%%%%"
This is using the jtds driver instead of
com.typesafe.slick.driver.ms.SQLServerDriver
Which appears to have been made deliberately difficult to use. I have not found a sucessful config with it. JTDS manages to create the 'suppliers' table based on it's schema, but all subsequent requests fall over with a nebulous 'data truncation' message;
object HelloSlick extends App {
val db = Database.forConfig("sqlServerLocal")
try {
// The query interface for the Suppliers table
val suppliers: TableQuery[Suppliers] = TableQuery[Suppliers]
val setupAction: DBIO[Unit] = DBIO.seq(
// Create the schema by combining the DDLs for the Suppliers and Coffees
// tables using the query interfaces
//(suppliers.schema).create,
// Insert some suppliers
suppliers += (101, "Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199"),
suppliers += ( 49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"),
suppliers += (150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966")
)
Telling me that
background log: info: 10:58:48.465 [sqlServerLocal-1] DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement: insert into "SUPPLIERS" ("SUP_ID","SUP_NAME","STREET","CITY","STATE","ZIP") values (?,?,?,?,?,?)
background log: error: Exception in thread "main" java.sql.DataTruncation: Data truncation
Does anyone have any ideas? Is connecting to SQL server with slick - 3.1 even a sensible thing to attempt?
EDIT::
#szeiger makes the excellent point that I'm importing the wrong thing into the model classes. I had the old H2 driver import from the Hello Slick example, which should be replaced with this;
import com.typesafe.slick.driver.ms.SQLServerDriver.api._
In order to work as a SQL server language.
After making this change, the DB configuration which 'did something' no longer works, advertising this
background log: info: Running HelloSlick
background log: error: Exception in thread "main" java.lang.NoClassDefFoundError: slick/profile/BasicProfile$SimpleQL
I've tried altering the instantiation of the actual db variable to match the 'recommended' strategy suggested by szeiger.
val db = Database.forURL("jdbc:sqlserver://%%%:1433;user=%%%%;password=%%%%", driver="com.typesafe.slick.driver.ms.SQLServerDriver",
executor = AsyncExecutor("test1", numThreads=10, queueSize=1000))
Unfortunately, this fails like so;
background log: error: Exception in thread "main" java.lang.NoClassDefFoundError: slick/profile/BasicProfile$Implicits
with the jtds driver, it has the same error message with the slick MSSQL driver, and despite my best efforts, I cannot instantiate the MS JDBC driver. It's in a folder called 'lib' in the application , although I suspected that might be naive and the wrong place.
Managing this dependency through play-slick would be excellent. I had thought that I would be doing that via the inclusion of this line in SBT;
"com.typesafe.play" %% "play-slick" % "1.1.0",
but appears to have no effect in isolation, and I'm unsure how to configure this to reach the 'official' slick MS SQL driver.
EDIT 2:: Finally, this appears to build what I want.
name := """hello-slick-3.1"""
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/"
resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"
resolvers += Resolver.url("Typesafe Ivy releases", url("https://repo.typesafe.com/typesafe/ivy-releases"))(Resolver.ivyStylePatterns)
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0",
"com.typesafe.play" %% "play-slick" % "1.1.0",
"org.scalatest" %% "scalatest" % "2.2.4" % "test"
)
I had lots of problems because I forgot to include the correct resolvers.
Don't forget to include the correct resolvers :-).
You're confusing Slick drivers and JDBC drivers. Which Slick driver are you using? The imports are missing from your snippet but there should be something like import com.typesafe.slick.driver.ms.SQLServerDriver.api._. Using a wrong driver here could explain String columns being created as VARCHAR(1).
The recommended way of configuring database connections in Slick 3.1 is via DatabaseConfig, which allows you to configure the Slick driver together with the actual connection parameters. When you're writing a Play app, use the play-slick plugin instead to handle database connections. It is also based on the DatabaseConfig syntax.
The alternative to net.sourceforge.jtds.jdbc.Driver would be Microsoft's own JDBC driver, com.microsoft.sqlserver.jdbc.SQLServerDriver which is available as a separate download from Microsoft. You have to manually add sqljdbc4.jar to your build to make this work.
BTW, Slick 3.2 will change terminology and use the word "driver" exclusively for JDBC drivers. Slick drivers will be called "profiles" in 3.2.
After bonus pain, it looks like slick creates columns in SQL Server as type 'varchar(1)'.
Which can't hold very much data.
Not using Slick to create the tables, and commenting out these lines then means that the intro works as advertised.

SSRS 2014 invalid namespace

I am trying to set up forms authentication on Reporting Server 2014. So far I was able to get rid of most of the errors but when trying to log in on reportserver/logon.aspx I get the following error:
An error occurred while attempting to get the ReportServer Url. Invalid namespace
I applied the following in web.config:
<add key="ReportServer" value="localhost"/>
<add key="ReportServerInstance" value="RS_SKOREPORTS"/>
The following is from my reportingservices.mof:
#pragma namespace ("\\\\.\\root\\Microsoft\\SqlServer\\ReportServer\\RS_SKOREPORTS\\V12")
I've tried several things like removing the RS_ prefix but the error remains.
EDIT:
Ok, I have come to the point where I know what's wrong by debugging everything, I just don't know how to fix it. My wmiNamespace string is adjusted for report server 2014 as follows: private const string wmiNamespace = #"\\{0}\root\Microsoft\SqlServer\ReportServer\RS_{1}\v12";
The weird thing is that when I debug the login process and put a watch on fullWmiNamespace the value it returns is:
"\\\\localhost\\root\\Microsoft\\SqlServer\\ReportServer\\RS_SKOREPORTS\\v10"
It looks like report server ignores the changes I made in AuthenticationUtilities.cs and just uses the unmodified version.
Fixed by hardcoding the wmiNamespace string. For some reason the FullWmiNamespace string didn't format the string properly..

Resources