I am fairly new to ApacheCamel and I am trying to integrate a TeraData DB call to our database and I cannot figure out the below error message. In addition, I am running this in fuse.
2016-01-22 16:17:36,725 [Blueprint Extender: 1] ERROR org.apache.aries.blueprint.container.BlueprintContainerImpl - Unable to start blueprint container for bundle fuse-maria-bundle
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find property descriptor URL on class com.teradata.jdbc.TeraDriver
What I have done so far is added the below in my blueprint.xml
<bean id="teradata" class="com.teradata.jdbc.TeraDriver">
<property name="URL" value="jdbc:teradata://[inser database connection]" />
<property name="user" value="myuser" />
<property name="password" value="mypassword" />
</bean>
I have this in my pom.xml
<dependency>
<groupId>com.teradata.jdbc</groupId>
<artifactId>terajdbc4</artifactId>
<version>15.10.00.14</version>
</dependency>
<dependency>
<groupId>com.teradata.jdbc</groupId>
<artifactId>tdgssconfig</artifactId>
<version>15.10.00.14</version>
</dependency>
...and followed the instruction from this link where I downloaded the driver from teradata.com.
In my route, I have the below code.
#Override
public void configure() throws Exception {
from("timer://testtimer?period=1000000")
.enrich("sql:select count(*) from table1?dataSource=#teradata")
.log("Processing ${body}");
}
Any ideas would help. Thanks in advance!
You have to download database drivers (terajdbc4.jar). I think, you
already have it...
Now you have to install drivers to your container (Karaf, because you wrote "Fuse").
Installing from file, windows example (if drivers not OSGi ready), Karaf console:
install -s wrap:file:///c:/install/terajdbc4.jar
or installing from Maven repository:
install -s wrap:mvn:com.teradata.jdbc/terajdbc4/15.10.00.14
Mission complete.
About converting jars:
https://access.redhat.com/documentation/en-US/Fuse_ESB_Enterprise/7.0/html/Deploying_into_the_Container/files/DeployJar-Wrap.html
UPDATED:
The problem is that class com.teradata.jdbc.TeraDriver has no properties url, URL, and so on...
I recomend you to try org.apache.commons.dbcp.BasicDataSource like this:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.teradata.jdbc.TeraDriver" />
<property name="url" value="jdbc:teradata://[inser database connection]" />
<property name="username" value="myuser" />
<property name="password" value="mypassword" />
</bean>
Second option is org.springframework.jdbc.datasource.DriverManagerDataSource:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="com.ncr.teradata.TeraDriver" />
<property name="url" value="jdbc:teradata://[inser database connection]" />
<property name="username" value="myuser" />
<property name="password" value="mypassword" />
</bean>
The error is specific to the property URL you set on the TeraDriver bean , doesnt look like that property is avaialble on the class , can you try using "url" in small case
Related
I am having some trouble configuring Spring to use BATCH_* tables hosted by MySQL.
I created the tables ok according to docs however it looks like the code is trying to get a sequence number using the Oracle flavour function.
The error I get is:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'BATCH_JOB_SEQ' in field list
But this is hiding the real problem. I debugged it and its trying to run this code:
select " + getIncrementerName() + ".nextval from dual";
Which is obviously Oracle dialect. I notice that there exists the correct incrementer in my environment here:
org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer()
but its calling
org.springframework.jdbc.support.incrementer.OracleMaxValueIncrementer()
I have setup my data source thus:
<bean id="springDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.252.205.5:3306/MASKNG" />
<property name="username" value="MASKNG" />
<property name="password" value="maskng" />
</bean>
Anyone have an ideas as this is a show stopper for us atm
Well, well, I really should RTM a little more...you just have to tell the jobRepository bean what type of DB you are using
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="springDataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="validateTransactionState" value="${jobRepository.validationTransactionState:true}" />
<property name="isolationLevelForCreate" value="${jobRepository.isolationLevelForCreate}" />
<!-- <property name="databaseType" value="oracle" /> -->
<property name="databaseType" value="mysql" />
<property name="tablePrefix" value="BATCH_" />
<property name="lobHandler" ref="lobHandler"/>
</bean>
I want to use Spring to connect to my local PostgreSQL db. I don't know if it is possible, cause I didn't find any tutorials for this. So is it possible? If yes, please explain me where can I find some fine tutorial. If no, how can I do it? I know I can make it via postgresql jdbc, but I want to do it like in real company.
Of course you can. The database vendor is immaterial. Java hides database details using JDBC.
Here is a Spring tutorial that shows you how to do it in 15 minutes or less.
First you need to create a spring project from https://start.spring.io/ and add postgresql to its dependencies. You will then see it build up in your pom.xml file. Then you have to enter the information of the postgresql database you want to connect to in the application.yml file.
Here is my example.
applicationContext.xml :
<!-- the setting msg -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/database.properties</value>
</list>
</property>
</bean>
<!-- PostgreSQL datasource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- ibatis client -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:config/SqlMapConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
I am trying to connect 2 different schemas within my spring boot application.
To do this I have got 2 different data sources. How should I configure this within my properties files?
I seen this answer which gave me an idea of how to do so. I currently have the following 3 property files in my application:
1. application.properties
2. hibernate.properties
3. multiple-db.properties
application.properties is currently empty. Below are the other 2 files:
hibernate.properties:
# Connection configuration
hibernate.connection.username= my_uname1
hibernate.connection.password= my_pword1
multiple-db.properties:
# Schema 1-Data source configuration
oracle.db.username1= my_uname1
oracle.db.password1= my_pword1
oracle.db.url1= my_url1
# Schema 2-Data source configuration
oracle.db.username2= my_uname2
oracle.db.password1= my_pword2
oracle.db.url2= my_url2
# JPA configuration
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
# Hibernate configuration
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.url=my_url
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
Is this the correct approach? Do I need 3 properties files, or could I do this all in one?
The Spring documentation suggests a way to create primary and secondary data sources:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-two-datasources
Each data source can be configured as described here:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-configure-a-datasource
You can access them by using #Autowire from other beans. You can associate a prefix to each data source so you can configure it in your application.properties or application.yml file.
You can also set one as primary.
With Spring you can do this easily.
It would be something like this:
<bean id="dataSource_1" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/northwind" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="dataSource_2" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/northwind_dup" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
You could also use your properties files and do something like this:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<context:property-placeholder location="jdbc.properties"/>
And you could use only one file, or three. It is really up to you.
I am trying to access a MS SQL database with apache camel. I am building it with maven as a bundle and deploy it on apache karaf.To do this I got the following in my blueprint.xml
<bean id="dataSource" class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<property name="url" value="" />
<property name="user" value="paygate" />
<property name="password" value="" />
</bean>
<service interface="javax.sql.DataSource" ref="dataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mssqlDatasource" />
</service-properties>
</service>
But now I am getting the following in my karaf logs
missing requirement [1374.6] osgi.wiring.package; (osgi.wiring.package=net.sourceforge.jtds.jdbcx)
This is the class that also was generated when creating the datasource in karaf with 'jdbc:create'.
Why doesn't karaf find that class?
Install the jtds jar as a bundle , using the command :
install -s wrap:mvn: net.sourceforge.jtds /jtds/1.3.0
Change version number to match your jar version, that will resolve the problem.
It is the MSSQL datasource,
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;databaseName=testdb"/>
<property name="username" value="sa"/>
<property name="password" value="root"/>
</bean>
Then you should install dbcp and jtds dependency in karaf container. It is working fine.
I'm trying to find the best way to create a dataSource in Spring for connecting to a Google Cloud SQL instance.
I'm currently using:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.GoogleDriver" />
<property name="url" value="jdbc:google:mysql://myappid:instanceId/mydb?user=myuser" />
<property name="username" value="myuser" />
<property name="password" value="mypassword" />
</bean>
However, I'm a little concerned about using the DriverManagerDataSource provided by Spring as it's documentation says it creates a new connection for every call.
Before migrating over to App Engine I was using a connection pool called BoneCP - however it uses classes that are restricted by App Engine. Is there a connection pool or some other data source class that is recommended to be used with Google Cloud SQL?
Try c3p0 or commons-dbcp. They both implement javax.sql.Datasource which is whitelisted by app-engine.
Example on commons-dbcp:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.GoogleDriver" />
<property name="url" value="jdbc:google:mysql://myappid:instanceId/mydb?user=myuser" />
<property name="username" value="myuser" />
<property name="password" value="mypassword" />
<property name="validationQuery" value="SELECT 1"/>
</bean>