I'm running tomcat6 and mysql5 on a single ec2 instance and i cannot cannot from the outside world.
My context.xml on tomcat in ec2...
<bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<property name="url" value="jdbc:mysql://ec2-xx-xx-xxx-178.compute1.amazonaws.com:3306/data_dbo" />
<property name="user" value="a_user" />
<property name="password" value="a_password" />
</bean>
Client context.xml
<bean id="myService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:8080/MyService-services/remoting/thingServiceExporter"/>
<property name="serviceInterface" value="com.things.services.MyService"/>
</bean>
Error on clinet...
Caused by: java.sql.SQLException: Access denied for user ''#'domU-xx-xx-xx-xx-xx-DB.compute-1.internal' (using password: NO)
I've setup privileges for my user but it doesn't seem to be using the user i setup in my tomcat datasource. I say this because of the error on the client (Access denied for user ''#) no user, no password. Do i need to setup something between tomcat and mysql on ec2 because it seems to be using the internal dns to access MySql?
Let me know if i can provide any other information!
I found the issue. My persistance.xml had the following code...
<properties>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.driver_class" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value=""/>
</properties>
Not sure how that got in there! The settings in the persistance.xml must override the settings in my Spring context file.
Related
I am stuggelin to create a ftp connection with the spring ftpSessionFactory.
In my project I am using the xml configuration for a ftp connection with TLS (it works):
<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpsSessionFactory">
<property name="host" value="#{configurationService.configuration.getProperty('file.transfer.server.host')}" />
<property name="port" value="#{configurationService.configuration.getProperty('file.transfer.server.port')}" />
<property name="username" value="#{configurationService.configuration.getProperty('file.transfer.server.user')}" />
<property name="password" value="#{configurationService.configuration.getProperty('file.transfer.server.password')}" />
<property name="clientMode" value="2"/>
<property name="fileType" value="2"/>
<property name="useClientMode" value="true"/>
<property name="keyManager" ref="keyManager"/>
<property name="protocol" value="TLS"/>
<property name="trustManager" ref="trustManager"/>
<property name="prot" value="P"/>
<property name="needClientAuth" value="true"/>
<property name="sessionCreation" value="true"/>
<property name="implicit" value="false"/>
</bean>
Now I need a second connection, but without TLS (dont ask :D). For that I just replaced the fields in Java:
ftpSessionFactory.setHost(host);
ftpSessionFactory.setPort(port);
ftpSessionFactory.setUsername(username);
ftpSessionFactory.setPassword(password);
ftpSessionFactory.setProtocol(StringUtils.isNoneEmpty(protocol) ? protocol : null); // <-- null for no TLS
But that gives me this error: javax.net.ssl.SSLException: 500 AUTH: unknown command.
Then I tried it the hard coded way (it works):
FTPClient f = new FTPClient();
f.connect(host);
f.login(username, password);
Now my question:
How can I modify the xml part (I guess with setter) so it works for both?
Use DefaultFtpSessionFactory instead of DefaultFtpsSessionFactory.
I have a spring application hosted on to the server (Tomcat 8.5). It goes idle if no one uses it. I already knew that timeout will occur if the DB is in idle state for 8 hours (Default timeout of MySQL). As mentioned in Spring Autoreconnect and Connection lost overnight post i have tried the solution available here.I have tried configuring application.properties but that doesn't bring any solution to the problem.
(PS:I'm not changing anything other than application.properties in my Spring Application).
Well if this
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 60000
spring.datasource.validationQuery = SELECT 1
or this
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
didnt work maybe try this
Post SpringBoot 1.4 names have changed
They have defined new specific namespaces for the four connections pools spring supports: tomcat, hikari, dbcp, dbcp2.
spring.datasource.tomcat.testOnBorrow=true
spring.datasource.tomcat.validationQuery=SELECT 1
If problem doesn't solve even after including properties as in application.properties, Then problem will be solved when including testOnBorrow,validationQuery in application-context.xml located in src/main/resources
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driver.classname}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="initialSize" value="2"/>
<property name="maxActive" value="50"/>
<property name="maxIdle" value="5"/>
<property name="maxWait" value="-1"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="600"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="true" />
<property name="validationQuery" value="SELECT 1" />
</bean>
The solution is to validate connection thread when it is borrowed from thread pool by enabling testOnBorrow and providing validationQuery.
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
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>
I am trying to setup an Amazon EC2 with tomcat and mysql. Both are up and running, both are in same instance. My confusions is, what jdbc url I have to use to connect my database on the same instance
<bean id="masterDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>WHAT TO ADD HERE</value>
</property>
.....
Add them like this:
<property name="url" value="jdbc:mysql://localhost/_dbName" />
<property name="username" value="your username" />
<property name="password" value="your password" />
Try the following:
jdbc:mysql://localhost/database_name?user=your_username&password=your_greatsqlpw
or
jdbc:mysql://127.0.0.1/database_name?user=your_username&password=your_greatsqlpw
As long as your server is secure you should not be concerned about security too much since the connections are only internal in the server.