Creating DB2 XA Datasource using JBoss-CLI - jboss-cli

I am trying to create DB2 XA Datasource using JBoss-cli using the following command.
/profile=full-ha/subsystem=datasources/xa-data-source=DB2DSXA3:add(jndi-name="java:/DB2DSXA3",connection-url="jdbc:db2://localhost:50000/TESTDB",driver-name=db2jccxa,is-same-rm-override="false",user-name=sambati,password=Summi135#,recover-plugin-class-name="org.jboss.jca.core.recovery.ConfigurableRecoveryPlugin",valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker",stale-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker",exception-sorter-class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter")
Looks like some mandatory fields are missing. i am getting the following error message:
connection-url' is not found among the supported properties: [allocation-retry, allocation-retry-wait-millis, allow-multiple-users, authentication-context, background-validation, background-validation-millis, blocking-timeout-wait-millis, capacity-decrementer-class, capacity-decrementer-properties, capacity-incrementer-class, capacity-incrementer-properties, check-valid-connection-sql, connectable, connection-listener-class, connection-listener-property, credential-reference, driver-name, elytron-enabled, enabled, enlistment-trace, exception-sorter-class-name, exception-sorter-properties, flush-strategy, idle-timeout-minutes, initial-pool-size, interleaving, jndi-name, max-pool-size, mcp, min-pool-size, new-connection-sql, no-recovery, no-tx-separate-pool, pad-xid, password, pool-fair, pool-prefill, pool-use-strict-min, prepared-statements-cache-size, query-timeout, reauth-plugin-class-name, reauth-plugin-properties, recovery-authentication-context, recovery-credential-reference, recovery-elytron-enabled, recovery-password, recovery-plugin-class-name, recovery-plugin-properties, recovery-security-domain, recovery-username, same-rm-override, security-domain, set-tx-query-timeout, share-prepared-statements, spy, stale-connection-checker-class-name, stale-connection-checker-properties, statistics-enabled, track-statements, tracking, transaction-isolation, url-delimiter, url-property, url-selector-strategy-class-name, use-ccm, use-fast-fail, use-java-context, use-try-lock, user-name, valid-connection-checker-class-name, valid-connection-checker-properties, validate-on-match, wrap-xa-resource, xa-datasource-class, xa-resource-timeout]
can some one help me please.

The error indicates that the connection-url is not a property on an xa-data-source resource. The connection URL will need to be added as a property in a batch command.
Here's an example MySQL CLI command:
module add --name=com.mysql --resources=~/Downloads/mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar --dependencies=javax.api,javax.transaction.api
batch
/subsystem=datasources/jdbc-driver=com.mysql:add(driver-name=com.mysql, driver-module-name=com.mysql, driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
/subsystem=datasources/xa-data-source=mysql:add(driver-name=com.mysql, jndi-name="java:/jdbc/MySQLXA", enabled=true)
/subsystem=datasources/xa-data-source=mysql/xa-datasource-properties=URL:add(value="jdbc:mysql://localhost:3306/temp?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8")
run-batch

Related

Mulesoft EC2 *describeInstances* with *filter* option

I'm having problems using the EC2 connector with filters for DescribeInstances. Specifically, I'm trying to find all instances that have the tag "classId" set.
I've also tried to find all instances that have the classId tag with specific string, e.g. "123".
Below are the XMLs of the describeInstance for both scenarios.
tag-key ------
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag-key" values="#[['classId']]">
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
tag:classId:----
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values >
<ec2:value value="#['123']" />
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Each time I receive an error like the following (for tag:classId):
ERROR 2021-03-29 08:32:49,693 [[MuleRuntime].uber.04: [ec2-play].ec2-playFlow.BLOCKING #1092a5bc] [processor: ; event: df5e2df0-908a-11eb-94b5-38f9d38da5c3] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: 
********************************************************************************
Message        : The filter 'null' is invalid (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 33e3bbfb-99ea-4382-932f-647662810c92; Proxy: null)
Element        : ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances)
Element DSL      : <ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values>
<ec2:value value="#['123']"></ec2:value>
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Error type      : EC2:INVALID_PARAMETER_VALUE
FlowStack       : at ec2-playFlow(ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances))
 (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
NOTE: The code works without a filter, returning all instances. But, that isn't what I want or need. The more filtering I can do the faster the response.
Does anyone have samples of the filter option working? Can you tell me what I'm doing wrong?
Thanks!
This surely is a bug. I tried the same and it was not working for me as well. I enabled debug logging and found that the connector is not sending the filter.1.Name=tag:classId as a query parameter in the request. Here is the debug log that I found. (Notice there is no filter.1.Name=tag:classId in the query string)
DEBUG 2021-04-02 21:55:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Value.1=123"
However, I tried to use the Expression or Bean Reference option and set the expression directly as [{name: 'tag:classId', values:['123']}] like this:
and it worked correctly. Here is the same debug log after this change
DEBUG 2021-04-02 21:59:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Name=tag%3AclassId&Filter.1.Value.1=123"
Also, I want to point out very weird behaviour, this does not work if you try to format [{name: 'tag:classId',values: ['123']}] across multiple lines in the expression and will give an error during deployment.

SPARK SQL (1.5.1) connect to Oracle and write to Avro

I am using spark-sql to connect to oracle databse and getting data as dataframes. I would like to write this retrieved data into avro file. While writing to avro I am seeing multiple issues, could you help us.
Here is the code -
val df = sqlContext.read.format("jdbc")
.options(Map( "driver"->"oracle.jdbc.driver.OracleDriver",
"url" -> "jdbc:oracle:thin:user/password#host/service"
, "numPartitions" -> "1", "dbtable"-> "
(Select * from schema.table WHERE STAGE_NUM <=39 and
guid='I284ba1f9cdba11dea82ab9f4ee295c21')"))
.load()
df.write.format("com.databricks.spark.avro").save("Outputfile")
Dependencies that are there in my project -
<dependency><br> <groupId>org.apache.spark</groupId><br> <artifactId>spark-sql_2.10</artifactId><br> <version>1.5.1</version><br></dependency><br><dependency><br> <groupId>com.databricks</groupId><br> <artifactId>spark-avro_2.10</artifactId><br> <version>2.0.1</version><br></dependency><br><dependency><br> <groupId>org.apache.avro</groupId><br> <artifactId>avro</artifactId><br> <version>1.7.7</version><br></dependency><br><dependency><br> <groupId>org.apache.avro</groupId><br> <artifactId>avro-mapred</artifactId><br> <version>1.7.7</version><br></dependency>
Here is the exception information -
java.lang.RuntimeException: com.databricks.spark.avro.DefaultSource does not allow create table as select
If I use - df.write.avro("headnotes"), I get the following exception.
java.lang.IllegalAccessError: tried to access class org.apache.avro.SchemaBuilder$FieldDefault from class com.databricks.spark.avro.SchemaConverters$$anonfun$convertStructToAvro$1

Bootstrapped Pattern Extraction Method Error while I tried patternScoring=LOGREG

I would like to try a pattern extraction method by using Stanford CoreNLP 3.6.0 on Ubuntu.
It worked as a default setting (through patterns/example.properties) by running Pattern Extraction method as follows:
java -mx1000m -cp "*" edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass -props patterns/example.properties
However, when I changed the Pattern Scoring setting in the example.properties to "patternScoring=LOGREG", I encountered an error as follows:
Cannot assign option field: java.lang.Class edu.stanford.nlp.patterns.ScorePhrases.phraseScorerClass value: edu.stanford.nlp.patterns.ScorePhrasesLearnFeatWt; invalid type
java.lang.RuntimeException: [Ljava.lang.Object;#466dd2b7
edu.stanford.nlp.util.logging.Redwood$Util.runtimeException(Redwood.java:973)
edu.stanford.nlp.util.Execution.fillField(Execution.java:243)
edu.stanford.nlp.util.Execution.fillOptionsImpl(Execution.java:477)
edu.stanford.nlp.util.Execution.fillOptionsImpl(Execution.java:536)
edu.stanford.nlp.util.Execution.fillOptions(Execution.java:599)
edu.stanford.nlp.util.Execution.fillOptions(Execution.java:603)
edu.stanford.nlp.patterns.ScorePhrases.<init>(ScorePhrases.java:50)
edu.stanford.nlp.patterns.ScorePatternsRatioModifiedFreq.convert2OneDim(ScorePatternsRatioModifiedFreq.java:198)
edu.stanford.nlp.patterns.ScorePatternsRatioModifiedFreq.score(ScorePatternsRatioModifiedFreq.java:89)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.getPatterns(GetPatternsFromDataMultiClass.java:1318)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.iterateExtractApply4Label(GetPatternsFromDataMultiClass.java:2310)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.iterateExtractApply(GetPatternsFromDataMultiClass.java:2124)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.runNineYards(GetPatternsFromDataMultiClass.java:3330)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.run(GetPatternsFromDataMultiClass.java:3310)
edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.main(GetPatternsFromDataMultiClass.java:3611)
Cannot assign option field: edu.stanford.nlp.patterns.ScorePhrases.phraseScorerClass value: edu.stanford.nlp.patterns.ScorePhrasesLearnFeatWt cause: [Ljava.lang.Object;#466dd2b7
java.lang.RuntimeException: [Ljava.lang.Object;#3cfb55fe
at edu.stanford.nlp.util.logging.Redwood$Util.runtimeException(Redwood.java:973)
at edu.stanford.nlp.util.Execution.fillField(Execution.java:257)
at edu.stanford.nlp.util.Execution.fillOptionsImpl(Execution.java:477)
at edu.stanford.nlp.util.Execution.fillOptionsImpl(Execution.java:536)
at edu.stanford.nlp.util.Execution.fillOptions(Execution.java:599)
at edu.stanford.nlp.util.Execution.fillOptions(Execution.java:603)
at edu.stanford.nlp.patterns.ScorePhrases.<init>(ScorePhrases.java:50)
at edu.stanford.nlp.patterns.ScorePatternsRatioModifiedFreq.convert2OneDim(ScorePatternsRatioModifiedFreq.java:198)
at edu.stanford.nlp.patterns.ScorePatternsRatioModifiedFreq.score(ScorePatternsRatioModifiedFreq.java:89)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.getPatterns(GetPatternsFromDataMultiClass.java:1318)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.iterateExtractApply4Label(GetPatternsFromDataMultiClass.java:2310)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.iterateExtractApply(GetPatternsFromDataMultiClass.java:2124)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.runNineYards(GetPatternsFromDataMultiClass.java:3330)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.run(GetPatternsFromDataMultiClass.java:3310)
at edu.stanford.nlp.patterns.GetPatternsFromDataMultiClass.main(GetPatternsFromDataMultiClass.java:3611)
Does someone know how to fix this problem?
Thanks,

Clojure: using ragtime with sqlite3

I'd like to use ragtime to manage migrations on an SQLite database. Following the instructions here, i've tried the following in the REPL:
(require '[ragtime.jdbc :as jdbc]
'[ragtime.repl :as repl])
(def config
{:datastore (jdbc/sql-database {:connection-uri "jdbc:sqlite:resources/db.sqlite3"})
:migrations (jdbc/load-resources "migrations")})
(repl/migrate config)
All I get is the following error:
ClassCastException clojure.lang.PersistentVector cannot be cast to clojure.lang.Named clojure.core/name (core.clj:1546)
The database file exists in resources/db.sqlite3. I've tried tracing the exception (i can add the stack trace if needed), but it seems to happen deep in clojure.java.jdbc.
As I'm new to the JVM and JDBC, I'm also not sure whether I'm specifying the :connection-uri correctly; I've tried several variants but can't seem to make it worK.
Any help would be much appreciated !
EDIT: stack trace:
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named
at clojure.core$name.invokeStatic (core.clj:1546)
clojure.core$name.invoke (core.clj:1540)
clojure.java.jdbc$as_sql_name.invokeStatic (jdbc.clj:67)
clojure.java.jdbc$as_sql_name.invoke (jdbc.clj:56)
clojure.java.jdbc$create_table_ddl$spec_to_string__2511.invoke (jdbc.clj:1052)
clojure.core$map$fn__4785.invoke (core.clj:2646)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.LazySeq.first (LazySeq.java:71)
clojure.lang.RT.first (RT.java:667)
clojure.core$first__4339.invokeStatic (core.clj:55)
clojure.string$join.invokeStatic (string.clj:180)
clojure.string$join.invoke (string.clj:180)
clojure.java.jdbc$create_table_ddl.invokeStatic (jdbc.clj:1056)
clojure.java.jdbc$create_table_ddl.doInvoke (jdbc.clj:1041)
clojure.lang.RestFn.invoke (RestFn.java:423)
ragtime.jdbc$migrations_table_ddl.invokeStatic (jdbc.clj:16)
ragtime.jdbc$migrations_table_ddl.invoke (jdbc.clj:15)
ragtime.jdbc$ensure_migrations_table_exists.invokeStatic (jdbc.clj:22)
ragtime.jdbc$ensure_migrations_table_exists.invoke (jdbc.clj:20)
ragtime.jdbc.SqlDatabase.applied_migration_ids (jdbc.clj:42)
ragtime.core$migrate_all.invokeStatic (core.clj:43)
ragtime.core$migrate_all.invoke (core.clj:32)
ragtime.repl$migrate.invokeStatic (repl.clj:49)
ragtime.repl$migrate.invoke (repl.clj:34)
thulium.core$eval8407.invokeStatic (form-init2686611279014890656.clj:1)
(the rest is REPL and compiler calls)
And the two migration files, resources/migrations/001-initial.up.sql:
CREATE TABLE tests (
id INTEGER PRIMARY KEY AUTOINCREMENT
);
and resources/migrations/001-initial.down.sql:
DROP TABLE tests;
Give it a go with these versions:
[org.clojure/java.jdbc "0.6.1"]
[org.xerial/sqlite-jdbc "3.8.7"]

Errors when creating table using cassandra-jdbc-1.2.1 jar

I am having some difficulty creating a column family (table) in cassandra via the cassandra-jdbc driver.
The cql command works correctly in cqlsh, but doesn't when using cassandra jdbc. I suspect this is something to do with the way I have defined my connection string. Any help would be greatly helpful.
Let me try and explain what I have done.
I have created a keyspace using cqlsh with the following command
CREATE KEYSPACE authdb WITH
REPLICATION = {
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
This is as per the documentation at: http://www.datastax.com/docs/1.2/cql_cli/cql/CREATE_KEYSPACE#cql-create-keyspace
I am able to create a table (column family) in cqlsh using
CREATE TABLE authdb.users(
user_name varchar PRIMARY KEY,
password varchar,
gender varchar,
session_token varchar,
birth_year bigint
);
This works correctly.
My problems start when I try to create the table using cassandra-jdbc-1.2.1.jar
The code I use is:
public static void createColumnFamily() {
try {
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
Connection con = DriverManager.getConnection("jdbc:cassandra://localhost:9160/authdb?version=3.0.0");
String qry = "CREATE TABLE authdb.users(" +
"user_name varchar PRIMARY KEY," +
"password varchar," +
"gender varchar," +
"session_token varchar," +
"birth_year bigint" +
")";
Statement smt = con.createStatement();
smt.executeUpdate(qry);
con.close();
} catch (Exception e) {
e.printStackTrace();
}
When using cassandra-jdbc-1.2.1.jar I get the following error:
main DEBUG jdbc.CassandraDriver - Final Properties to Connection: {cqlVersion=3.0.0, portNumber=9160, databaseName=authdb, serverName=localhost}
main DEBUG jdbc.CassandraConnection - Connected to localhost:9160 in Cluster 'authdb' using Keyspace 'Test Cluster' and CQL version '3.0.0'
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Ljava/nio/ByteBuffer;Lorg/apache/cassandra/thrift/Compression;Lorg/apache/cassandra/thrift/ConsistencyLevel;)Lorg/apache/cassandra/thrift/CqlResult;
at org.apache.cassandra.cql.jdbc.CassandraConnection.execute(CassandraConnection.java:447)
Note: the cluster and key space are not correct
When using cassandra-jdbc-1.1.2.jar I get the following error:
main DEBUG jdbc.CassandraDriver - Final Properties to Connection: {cqlVersion=3.0.0, portNumber=9160, databaseName=authdb, serverName=localhost}
main INFO jdbc.CassandraConnection - Connected to localhost:9160 using Keyspace authdb and CQL version 3.0.0
java.sql.SQLSyntaxErrorException: Cannot execute/prepare CQL2 statement since the CQL has been set to CQL3(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+).
Note: in this instance the cluster and keyspace appear to be correct.
The error when using the 1.2.1 jar is because you have an old version of the cassandra-thrift jar. You need to keep that in sync with the cassandra-jdbc version. The cassandra-thrift jar is in the lib directory of the binary download.

Resources