facebook

connecting to a dblink using JPA/Spring

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #301230 Reply

    mahtab
    Member

    Hi all

    I have question.I use Jpa/Spring in MyEclipse to connect to my database which is on Oracle 10g. Currently a new database link has been introduced on our database and I’m required to select from that db and update it.My question is how do I do that?Do I need to set any extra parameters in persisteance.xml? where do I set the dblink name? Please help me.

    mahtab

    #301258 Reply

    mahtab,

    Your question is not clear.If you want to change to another database(ex:mysql) with the same table name and same structure in your existing oracle 10g, you can do the following:
    1) Add corresponding database jar(MySql) as a referenced libraries to your project.
    2) Remove the attribute “schema” from @Table annotation in generated bean class.
    3) Create another persistence unit in “persistence.xml” file

    <persistence-unit name=”MySqlJpaSpringPU”
    transaction-type=”RESOURCE_LOCAL”>
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <class>com.test.Tester</class>
    <properties>
    <property name = “toplink.jdbc.driver” value = “org.gjt.mm.mysql.Driver”/>
    <property name = “toplink.jdbc.url” value = “jdbc:mysql://localhost:3306/test”/>
    <property name = “toplink.jdbc.user” value = “root”/>
    <property name = “toplink.jdbc.password” value = “root”/>
    </properties>
    </persistence-unit>
    4) Add <property name=”toplink.jdbc.schema” value=”Your Schema Name” /> tag along with the above listed properties.
    5) Edit the following entry in “applicationcontext.xml” file

    <bean id=”entityManagerFactory”
    class=”org.springframework.orm.jpa.LocalEntityManagerFactoryBean”>
    <property name=”persistenceUnitName” value=”MySqlJpaSpringPU” />
    </bean>
    There might be other different ways to do this too. I would recommend you to investigate over the net.

    #301307 Reply

    mahtab
    Member

    Support-Shalini,

    No. I don’t want to change to another database.I want to use a database link(drda) in my original oracle 10g database which links my database to a DB2 database. I can select from drda tables in sqldeveloper but I cannot see them when connecting to db with MyEclipse nor can I create JPA mappings for those tables.

    please tell me what to do

    #301387 Reply

    mahtab,
    I am not sure how this can be done.
    I will escalate this to a dev team member.
    I will also recommend you to crosspost to other relevant forums. Sorry for the inconvinience

    #301404 Reply

    Loyal Water
    Member

    mahtab,
    This sounds like an Oracle DB feature that we are not familiar with — MyEclipse doesn’t offer any direct tooling for Oracle “links”… I get the impression they are some sort of abstraction-passthrough, allowing oRacle to present data from other data sources… as long as the JDBC driver can see it as a data source, our DB tools *will* support it — I just don’t know how to set all that up. Sorry about that.

    #301468 Reply

    mahtab
    Member

    Niptun,

    This is a passthrough to another DB.JDBC however does support it without any difficulties.I was able to directly connect to tables on the database link and make a queries to them with a JDBC connection.It seems to me your database tool does not support it.The tables of the database link are not shown in the database explorer perspective nor can I access them while generating Entities and DAOs with JPA reverse engineering.
    The funny thing is that I could create a view in sql developer using the table in the database link.Now I cansee that view in MyEclipse and reverse engineer it to an entity.Not sure though whether that would be helpful.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: connecting to a dblink using JPA/Spring

You must be logged in to post in the forum log in