I m trying to use a scriptella script to transfer some data to data in one server to another.
The script looks something like this
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>
test script
</description>
<properties>
<include href="../config/kpoint-etl.properties"/>
</properties>
<connection id="in" driver="${driver}" url="${url}" user="${user}" password="${password}">
</connection>
<connection id="out" driver="${driver}" url="${url2}" user="${user}" password="${password}">
</connection>
<query connection-id="in">
SELECT owner_name, owner_domain, DATE(time_last_update)
as pdate, count(*) as avg from kapsule where DATE(time_last_update)="2013-06-19" group by owner_name;
<script connection-id="out">
UPDATE test SET username=?owner_name, domain=?owner_domain, frequency=?avg, rdate=?pdate;
</script>
</query>
</etl>
the 'in' connection id seems to be working fine, but on connection to the second server it shows the following error.
JDBC provider exception: Unable to obtain
connection for URL jdbc:/mysql://localhost:3306/leopard
Error codes: [08001, 0]
Driver exception: java.sql.SQLException: No suitable
driver found for jdbc:/mysql://localhost:3306/leopard
The properties file is something like this
driver=mysql
url=jdbc:mysql://192.168.8.72:3306/leopard
user=leopard
password=user12
url2=jdbc:/mysql://localhost:3306/leopard
Any help will be appreciated. Thank You.
P.s. Do ask for any doubts regarding the question.
You have an extra slash in the second url jdbc:/mysql. Try removing it.
Related
I'm working on a Java EE 7 project that connects to a MySQL database. When I try to make any API calls via Swagger Inspector (while the server is running and the .war is deployed, of course), I get the below errors:
org.hibernate.exception.SQLGrammarException: could not prepare statement
and
`Caused by: org.h2.jdbc.JdbcSQLException: Table "APARTMENTS" not found; SQL statement:
select apartment0_.id as id1_0_, apartment0_.apt as apt2_0_, apartment0_.city as city3_0_, apartment0_.country as country4_0_, apartment0_.numberOfBedrooms as numberOf5_0_, apartment0_.postalCode as postalCo6_0_, apartment0_.state as state7_0_, apartment0_.street as street8_0_ from apartments apartment0_ order by apartment0_.postalCode [42102-197]`
The things that stand out to me are that, first, I'm not using Hibernate to my knowledge. Pretty sure I'm using JPQL. Second, I'm not trying to connect to a H2 database. So why would I get errors related to technology I'm not using?
I'm using Intellij and was able to add the correct MySQL DB within the IDE.
Here's an example of one of the SQL query methods, in case I really am somehow using incorrect syntax:
public List findAll() {
TypedQuery query = em.createQuery("SELECT a from Apartment a order by a.postalCode",Apartment.class);
return query.getResultList();
}`
Pretty lost and confused, and new to this, so any help would be appreciated!
Edit (8/11/21 5:11PM CST) to add persistence.xml:
` <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="rentRantPU">
<class>com.rentRant.rentRant.model.Apartment</class>
<class>com.rentRant.rentRant.model.User</class>
<class>com.rentRant.rentRant.model.Review</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/rentRant"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="****"/>
</properties>
</persistence-unit>
</persistence>`
Requirement: Run the below XMLA script on a particular node of SQL server 2012 and store the output data in a file or an SQL table
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_XML_METADATA</RequestType>
<Restrictions>
<RestrictionList>
<ObjectExpansion>ExpandObject</ObjectExpansion>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
</PropertyList>
</Properties>
I'm not finding any component in SSIS that could run the XMLA script and store the results. let me know is it possible in any other ways.
Like #sebTHU said you could use a SSAS DMV:
Select [CUBE_NAME], LAST_DATA_UPDATE from $system.MDSCHEMA_CUBES
However, if you want to list all the databases and their last processed date, install ASSP and then run this:
CALL ASSP.DiscoverXmlMetadataFull("\Databases\Database", "" ,"<ObjectExpansion>ExpandObject</ObjectExpansion>")
You could use a linked server or a .NET source component in SSIS.
So I'm trying to use dates with mysql on the wso2 dss.
Simple code
<query id="testDates" useConfig="PORTFOLIOS_DS">
<sql>
SELECT DATE(date) AS date FROM dateTest
</sql>
<result element="jsonObject" rowName="jsonArray">
<element column="date" name="testDate" xsdType="date"/>
</result>
</query>
So it returns "2015-03-10-04:00" which isn't considered a valid date my many libraries (momentJS in particular) and to be fair it is a strange format, why do I care about timezone without the time.
Does anyone know why it is appending the timezone, how can I prevent the appending of timezone to dates but leave it on datetimes?
I was able to reproduce this issue with DSS 3.5.0 version. So I have already created a public JIRA ticket [1]. and once this is fixed I will notify you.
In the meantime as a workaround, I would like to suggest to use an XSLT transformation to trip off timezone information. For more information about how to use XSLT inside the DSS server please refer [2]
[1]. https://wso2.org/jira/browse/DS-1191
[2]. https://docs.wso2.com/display/DSS350/XSLT+Transformation+Sample
I am trying to create an event formatter for MySql in WSO2 but am hitting a problem. It appears to be linked to the use of "Composite Key Columns". The error I am getting is:
ERROR - {MysqlEventAdaptorType}
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Window = '15'' at line 1
This only happens if I use a two or more keys in the formatter:
<eventFormatter name="GenericAccountSQLFormatter" statistics="enable"
trace="enable" xmlns="http://wso2.org/carbon/eventformatter">
<from streamName="GenericAccountMeasureStream" version="1.0.0"/>
<mapping customMapping="disable" type="map"/>
<to eventAdaptorName="APCSQLOut" eventAdaptorType="mysql">
<property name="table.name">AccountStats</property>
<property name="update.keys">AccountId,Window</property>
<property name="execution.mode">insert-or-update</property>
</to>
</eventFormatter>
Removing either of the keys (AccountId, Window) then the formatter will send data to MySQL.
Can anyone help?
This is a bug and happens when existing events are sent to a MySQL adaptor with composite keys. Created a jira to track this and the source patch is also available there.
If you don't want to create/apply a patch, then as a quick workaround for now - you can output a composite key from CEP query by concatenating the two attributes and use that as the key in formatter.
UPDATE
The source patch with the fix and build instructions are now available in the jira here. Once built, you need to apply it as a patch to CEP. To apply it as a patch, create a directory named patch0xyz ( xyz are digits as in patch0135, also make xyz > 100) in <CEP>/repository/components/patches and then place the jar inside it. Then you need to rename the jar as org.wso2.carbon.event.output.adaptor.mysql_1.0.1.jar. Then restart the server.
I was wondering if it is possible for Magento have a connection to its primary database, as well as another database that does not contain Magento's core information?
For example, I would like to be able to query tables from a WordPress install that is stored on a different database on a different server?
My first instinct was to create a new database connection using mysql_connect, but it does not feel right to do it this way.
Is there a more "proper" way to accomplish this?
here the complete explanation: http://fishpig.co.uk/magento-tutorials/create-an-external-database-connection-in-magento
in short, you need to create a new resource and tell magento to use this resource for your model, ie, in the config.xml, inside <global> tag:
<resources>
<external_db>
<connection>
<host><![CDATA[host]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[dbname]]></dbname>
<model>mysql4</model>
<type>pdo_mysql</type>
<active>1</active>
</connection>
</external_db>
<yourmodelalias_read>
<connection>
<use>external_db</use>
</connection>
</yourmodelalias_read>
</resources>
If you look in /lib/Varien/Db/Adapter/Mysqli.php you can see that Magento is extending the Zend_Db_Adapter_Mysqli, and in the _connect() function it is checking if the cached copy of the connection exists immediately.
To me it seems unlikely that using the Magento Db Adapter directly will work, as you would have to override this functionality. So, that leaves two options:
Use the Zend DB adapter, which is pretty easy if you have used it before.
Just use PHP's MySQL functions directly. Make sure to use the PDO or MySQLi libraries, not the ext/mysql. The ext/mysql library is getting deprecated and is a pain to use securely.
http://php.net/manual/en/ref.pdo-mysql.php
http://php.net/manual/en/book.mysqli.php
http://framework.zend.com/manual/en/zend.db.html
Edit: Adding Magento Connect Module
http://www.magentocommerce.com/magento-connect/fishpig/extension/3958/fishpig_wordpress_integration
That is a free Magento->Wordpress bridge. It may be worth looking into their source to see what path they took.
In your module etc/config.xml add following code:
<global>
<resources>
<modulename_write>
<connection>
<use>modulename_database</use>
</connection>
</modulename_write>
<modulename_read>
<connection>
<use>modulename_database</use>
</connection>
</modulename_read>
<modulename_setup>
<connection>
<use>core_setup</use>
</connection>
</modulename_setup>
<modulename_database>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[db_username]]></username>
<password><![CDATA[db_password]]></password>
<dbname><![CDATA[tablename]]></dbname>
<model>mysql4</model>
<type>pdo_mysql</type>
<active>1</active>
</connection>
</modulename_database>
</resources>
</global>
To get data from table using new database:
<?php
$resource = Mage::getSingleton('core/resource');
$conn = $resource->getConnection('modulename_read');
$results = $conn->fetchAll('SELECT * FROM tablename');
echo "<pre>";
print_r($results);
?>