Mysql datasource and WebDynpro

Hello all!
I'm new at WD and NW features and I'm trying to figure out the best way to access an external Mysql database with webdynpro.
I already configured an external mysql datasource at NW CE and it's working fine.
My doubt is about how I'm going to access this datasource in NWDS? Do I need to create a new Dictionary? How does it work? How do I link this datasource with my WebDynpro project?
And about the persistence? Must I use JPA, EJB? How do I do it?
Is there any article about this?

Hi,
there are already a lot of examples in the forum of how to connect MySql db with the portal.
Here is a simple solution:
If you have already created a datasource:
try {
               InitialContext initialContext = new InitialContext();
               DataSource dataSource = (DataSource)initialContext.lookup("jdbc/YOUR_DB_ALIAS");
               connection= dataSource.getConnection();
          } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (NamingException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
And you must change YOUR_DB_ALIAS with the real alias name. That is all if you have already created a datasource.
About what to use: you can use whatever you want. This is just a simple example of how to get your db connection. After that you can do whatever you want with it.
You can write your one db engine if you want:
                        PreparedStatement stmt = connection.prepareStatement("insert into simple_table simple_values(?)");
               stmt.setString(1, "Hello world");
               stmt.execute();
Or you can use JPA, JDO, EJB, etc... It depends only on your decision. All of them will work.

Similar Messages

  • Orion, DataSource and mySQL

    Hi,
    I'm having a problem receiving a connection from a DataSource through my appserver - Orion. I've entered the following into data-sources.xml:
         <data-source
              class="org.gjt.mm.mysql.MysqlDataSource"
              name="MySQL"
              location="jdbc/MyDB"
              connection-driver="org.gjt.mm.mysql.Driver"
              username="foo"
              password="foo"
              port="3306"
              url="jdbc:mysql://localhost/MyDB"
              inactivity-timeout="0"
         />     I then attempt to receive a connection in a JSP file:
                Context ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup("jdbc/MyDB");
                connection = ds.getConnection("foo","foo");When I the query the database I get an error, saying that no database has been selected. I have tried this without datasources, and it works, but I would prefer the usage of DataSources. What have I done wrong?
    Thanks on advance,
    Nille

    When using DataSource you shouldn't use URL. Use the host and maybe the properties instead. This is a working XA DataSource for Mimer SQL. I think the syntax is the same.
    <data-source
         name="MimerXADataSourceMulti1"
         location="jdbc/MimerXADataSourceMulti1"
         class="com.mimer.jdbc.MimerXADataSource"
         username="fredrika"
         password="fredrika"
         host="localhost"
         schema="database-schemas/mimer.xml">
         <property name="databaseName" value="multi1" />
    </data-source>
    A MySQL datasource might look like (I haven't tried this):
    <data-source
         class="org.gjt.mm.mysql.MysqlDataSource"
         name="MySQL"
         location="jdbc/MyDB"
         connection-driver="org.gjt.mm.mysql.Driver"
         username="foo"
         password="foo"
         port="3306"
    host="localhost"
         inactivity-timeout="0"
    <property name="databaseName" value="MyDB" />
    />     
    Regards,
    Fredrik

  • Setup MySQL datasource for Sun ONE Studio

    Hello all,
    I've tried to post this message on the Sun ONE studio forum, however, there were compilation errors with JSP pages. As I needed the answer urgently, I decided to get some help here.
    I've successfully made connection to MySQL database during the CMP development. However, when I tried to run it, it said the JNDI Datasource can't be blank and provide username & password if necessary. I went back and gave it a name as jdbc/MySQL, and also provided the username & password. I then reran the app, and I got the following error
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: Unable to get JDBC DataSource for CMP ....
    I've mounted the mysql.jar and hacked some other things to no success. Please help.
    Thanks & regards,
    Thinh

    Hi,
    Try validating your data source using
    http://developer.iplanet.com/tech/tools/dbping_overview.jsp
    Get back in case of any issues

  • Problem running Page with MySQL DataSource

    Hi All,
    Jdev Version 11.1.1.6.0
    I have created a MYSQL Datasource (Datasource got created successfully and tested). The issue is when I am running a jspx page, I am getting below exception.
    java.lang.NoClassDefFoundError: com/mysql/jdbc/MySQLConnection
    I have provided the Class path in Weblogic - Servers - DefaultServer- Server Start tab like C:\Users\jars\Downloads\mysql-connector-java-5.1.25\mysql-connector-java-5.1.25
    But still I am getting this exception. I didn't got any issue when I created a MYSQL connection, and provided Driver Class path.
    Any pointer, what I am missing here.
    Thanks
    AP

    Hi Suresh,
    Thanks for the post. Well there are 2 thing which I require to understand.
    1. We can create MYSQL connection using Jdev and set the classpath which is provided in post. It worked fine.
    2. We can create datasource of MYSQL connection and use it in our Model Project. Here I am struck and giving this exception when running.
    Since it Enterprise Application, creating Datasource is generic way to connecting. I am facing issue after creating datasource. I tried above approaches, but getting exception.
    Can you help me in understand, what is going wrong in step 2.
    Thanks, AP

  • Problem configure mysql datasource

    Hi, I am trying to use mysql datasource for my application. I had configured MYSQL_DRIVER and then
    i had configured gtasappdb datasource with
       driver-class-name = com.mysql.jdbc.Driver
       url               = jdbc:mysql://localhost:3306/appdb
       alias             = appdbdatasource
    And then i tried to deploy a EJB application which uses the above 'appdbdatasource'. When the application starts
    it says cannot find 'gtasappdb' connectionfactory.
    So can anyone tell me what should be done to use mysql for my application, please

    Hello mahesh,
    There are two ways.
    1. You should add a resource reference to the ds alias in the deployment descriptor of the application component.Once you have defined the reference,use the following snippet to access the data source
    DataSource ds = (DataSource) context.lookup("java:comp/env/<res-ref-name>").
    2. If you have not defined the reference in your application, use the JNDI reference "jdbc/alias".
    Hope this helps,
    Prasad

  • Problems creating MySQL Datasource in OC4J

    I was recently tasked with creating a MySQL datasource in my development OC4J container (running through Eclipse, but that's irrelevant). I searched for and found this page: http://www.oracle.com/technology/products/jdev/tips/duff/mysql_and_oc4j3.html which tells me how to do this.
    I searched for and found the Datasource class jar file: mysql-connector-java-3.0.17-ga-bin.jar, installing it in the ORACLE_HOME/applib directory of my container.
    I then fired up the container, and accessed the ascontrol app to add the Datasource (via Administration/JDBC options), and ran into a few problems:
    After entering the "Create Datasource" menu, I filled in the appropriate values for the JNDI name, class name of the Datasource, URL of the database, username and password. When I went to test the connection, I received an error that the Datasource class could not be created, yet in the error message it showed me where the Datasource class was (in which jar), so obviously the container knew about the jar.
    After much playing around, I determined that the ascontrol app itself was the issue. In the orion-application.xml file for the ascontrol found in ORACLE_HOME/application-deployments/ascontrol, I found the line:
    <remove-inherited name="global.libraries"/>
    in the <imported-shared-libraries> tag. This essentially means, "ignore everything in the applib directory". It seems, as the instructions in the page above state, you actually have to manually edit the data-sources.xml file in your ORACLE_HOME/config directory in order to add this datasource, as the ascontrol app is unable to do so without loading the library from applib.
    Now, I just commented out this line in the ascontrol's xml file temporarily, and was able to use the ascontrol to add the datasource, but this seems wrong. Now, finally, I can ask my questions:
    1. Is this really the preferred method for adding a MySQL datasource to an OC4J container?
    2. If not, what is?
    3. If so, why is the ascontrol crippled in this fashion, and should it be fixed so it isn't anymore?

    Tank -- we recently discovered this situation with ASC ourselves. There's some history there in that by importing the global.libraries in the past, there has been problems with some libs that ASC itself needed being overridden -- evidently some common practice with a framework we supply was to use the applib directory in this manner, which caused issues for ASC. So the solution was to remove global.libraries from ASC.
    OK so how to solve it, there's a number of options.
    1. Remove the remove-inherited libraries tag from the ASC deployment descriptor as you've identified. I actually have the ASC team checking on whether this is something they want to do in a patch release.
    2. Put the mysql driver into its own installed shared-library, then import that into each app that needs it. And add it to ASC as an imported-shared-library. That way the same code-source is available in each location. I'd have to say this is probably the preferred option at this point.
    3. Put the mysql jar file into both the j2ee/home/applib directory AND the web-inf/lib directory of the so both apps have at it. This introduces an abstract dependency, which may cause issues if you update one but not the other at some future point. But it should work.
    cheers
    -steve-

  • Difference between MySQL null and JAVA null

    When I create a new record in my MySQL db and some of the values are not intered, MySQL thinks of them as null. Java makes an error when the variable is used. But when I set the values to ' ' (blank) java sees it as null and makes no error.
    Is there a way around that??????
    BR Soren

    "" and null is totally different thing.
    you can try checking for null instead of "".

  • UI Control options do not appear for TCD mode and Webdynpro mode

    Hi guys,
    When I open the screen Start option in eCATT for ECC 7.0, there is no options for TCD mode and Webdynpro mode, only have for SAPGUI mode. So pls help to me find the options for these modes.
    Thanks in advance,
    Thien

    Hello Friend,
    This has been corrected by  640  SAPKB64023 and 700 SAPKB70016.
    Please install the relevant SP to your system.
    Thanks.
    Eric Monteiro

  • How to use DataSource and External transaction in 9ias?

    I'm working on a project that the application server needs to connect to over 100 databases.
    I'd like to use connection pooling and external transaction service defined in OC4J's Datasources.
    I wonder if anyone has an example of using datasource and external transaction service for OC4J.
    Right now, I export toplink project to a java source and do the initialization there manually but I don't know how to use Datasource to get connections and how to use the external transaction service in the java code for OC4J.
    I really appreciate you help.
    Wei

    Here is a fill in the blank example on how you could set this up through code:
    Project project = new MyProject();
    // alternatively, use the XMLProjectReader
    server = project.createServerSession();
    server.getLogin().useExternalConnectionPooling();
    server.getLogin().setConnector(new JNDIConnector(new javax.naming.InitialContext(), "jdbc/DataSourceName"));
    // the next line depends on the type of driver you want to use.
    server.getLogin().useOracleThinJDBCDriver();
    server.getLogin().useOracle();
    server.getLogin().setUserName("username");
    server.getLogin().setPassword("password");
    server.getLogin().useExternalTransactionController();
    server.setExternalTransactionController(new Oracle9iJTSExternalTransactionController());
    server.logMessages();
    server.login();

  • What should i do with an Oracle 11g Database, MySQL database and a dump file.

    I just joining to a new work field, almost about a database and i know "NOTHING" about this field.
    My company has a system that running by Oracle Database, the problem is that Oracle Database will cost a lot of money when my company expands.
    So the quest is converting Oracle Database to MySQL database.
    Of course i cant try to convert it in the main Database, so i create one Oracle 11g Database on my LocalHost, and it already actived in " Localhost:1158 " etc.
    I have another Sever test that already set up MySQL database, and a dump file from the system.
    So I want to ask these 2 questions :
    1. How to create an new Oracle Database from that dump file ?
    2. Is it alright if i use tool to convert Oracle Database into MySql, or i should do it manually ?
    Thanks alot.

    I just joining to a new work field, almost about a database and i know "NOTHING" about this field.
    My company has a system that running by Oracle Database, the problem is that Oracle Database will cost a lot of money when my company expands.
    So the quest is converting Oracle Database to MySQL database.
    I predict that converting to MySQL will cost your company more as it expands. As you expand managing contention becomes more important - Oracle does this for you. I do not think MySQL does, so you'll have to write more code to deal with this, costing the company money. A big part of making application scalable and reliable is to use stored procedures, how good are MySQL's compared to PL/SQL's. What other features are there that MySQL has that will benefit your company that Oracle doesn't. What do you need to think about as your company expands that need to be taken care of in the database. I would have thought a migration from MySQL to Oracle would be more common to deal with expansion.
    As you know "NOTHING" you need to think about what each database can give you for the next 10 years to cope with you businesses potential requirements, and extimate how much it will cost to implement these requirements, then make the decision

  • Compare creation of Datasources and JMS Queues : SAP vs (Weblogic/Websphere

    I am used to creating JDBC Datasources and JMS Queues on Weblogic/Websphere thru their Admin applications.
    Can someone compare/contrast that process to that on SAP's netweaver ( either using NWA or Visual Administrator).
    Thanks

    Hi Parag,
    For the process of creating JDBC datasources and JMS resources @ SAP NetWeaver you can refer to the documents here on SDN and help.sap.com, and compare that process for yourself, thus not being influenced by others' biased or unbiased opinions.
    For NetWeaver 04 and 04s these would be:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm">JDBC Connector Service</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/22/cf4e71c46cdb4da31153be96c5389f/frameset.htm">JMS Connector Service</a>
    For the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/javaee5">Java EE 5 Edition</a>:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7bb9751d-0e01-0010-febd-c3adce2c408c">Working with Database Tables, DataSources and JMS Resources</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/806e75a0-0e01-0010-2587-fc518de8ac1a">Administration Guide</a> -> section "Application Resources Management" (pages 89-104)
    Hope that helps!
    Your feedback/findings are very welcome!
    -Vladimir

  • What are the settings for datasource and infopackage for flat file loading

    hI
    Im trying to load the data from flat file to DSO . can anyone tel me what are the settings for datasource and infopackage for flat file loading .
    pls let me know
    regards
    kumar

    Loading of transaction data in BI 7.0:step by step guide on how to load data from a flatfile into the BI 7 system
    Uploading of Transaction data
    Log on to your SAP
    Transaction code RSA1—LEAD YOU TO MODELLING
    1. Creation of Info Objects
    • In left panel select info object
    • Create info area
    • Create info object catalog ( characteristics & Key figures ) by right clicking the created info area
    • Create new characteristics and key figures under respective catalogs according to the project requirement
    • Create required info objects and Activate.
    2. Creation of Data Source
    • In the left panel select data sources
    • Create application component(AC)
    • Right click AC and create datasource
    • Specify data source name, source system, and data type ( Transaction data )
    • In general tab give short, medium, and long description.
    • In extraction tab specify file path, header rows to be ignored, data format(csv) and data separator( , )
    • In proposal tab load example data and verify it.
    • In field tab you can you can give the technical name of info objects in the template and you not have to map during the transformation the server will automatically map accordingly. If you are not mapping in this field tab you have to manually map during the transformation in Info providers.
    • Activate data source and read preview data under preview tab.
    • Create info package by right clicking data source and in schedule tab click star to load data to PSA.( make sure to close the flat file during loading )
    3. Creation of data targets
    • In left panel select info provider
    • Select created info area and right click to create ODS( Data store object ) or Cube.
    • Specify name fro the ODS or cube and click create
    • From the template window select the required characteristics and key figures and drag and drop it into the DATA FIELD and KEY FIELDS
    • Click Activate.
    • Right click on ODS or Cube and select create transformation.
    • In source of transformation , select object type( data source) and specify its name and source system Note: Source system will be a temporary folder or package into which data is getting stored
    • Activate created transformation
    • Create Data transfer process (DTP) by right clicking the master data attributes
    • In extraction tab specify extraction mode ( full)
    • In update tab specify error handling ( request green)
    • Activate DTP and in execute tab click execute button to load data in data targets.
    4. Monitor
    Right Click data targets and select manage and in contents tab select contents to view the loaded data. There are two tables in ODS new table and active table to load data from new table to active table you have to activate after selecting the loaded data . Alternatively monitor icon can be used.
    Loading of master data in BI 7.0:
    For Uploading of master data in BI 7.0
    Log on to your SAP
    Transaction code RSA1—LEAD YOU TO MODELLING
    1. Creation of Info Objects
    • In left panel select info object
    • Create info area
    • Create info object catalog ( characteristics & Key figures ) by right clicking the created info area
    • Create new characteristics and key figures under respective catalogs according to the project requirement
    • Create required info objects and Activate.
    2. Creation of Data Source
    • In the left panel select data sources
    • Create application component(AC)
    • Right click AC and create datasource
    • Specify data source name, source system, and data type ( master data attributes, text, hierarchies)
    • In general tab give short, medium, and long description.
    • In extraction tab specify file path, header rows to be ignored, data format(csv) and data separator( , )
    • In proposal tab load example data and verify it.
    • In field tab you can you can give the technical name of info objects in the template and you not have to map during the transformation the server will automatically map accordingly. If you are not mapping in this field tab you have to manually map during the transformation in Info providers.
    • Activate data source and read preview data under preview tab.
    • Create info package by right clicking data source and in schedule tab click star to load data to PSA.( make sure to close the flat file during loading )
    3. Creation of data targets
    • In left panel select info provider
    • Select created info area and right click to select Insert Characteristics as info provider
    • Select required info object ( Ex : Employee ID)
    • Under that info object select attributes
    • Right click on attributes and select create transformation.
    • In source of transformation , select object type( data source) and specify its name and source system Note: Source system will be a temporary folder or package into which data is getting stored
    • Activate created transformation
    • Create Data transfer process (DTP) by right clicking the master data attributes
    • In extraction tab specify extraction mode ( full)
    • In update tab specify error handling ( request green)
    • Activate DTP and in execute tab click execute button to load data in data targets.

  • How can I include a MySQL table and records with the PUT of my Dreamweaver site?

    I am using .php to validate a user code against one of four codes that I am providing to potential clients.  They enter that code, along with a default user id and the appropriate page is then displayed for them.  Everything is working fine on the desktop.  I need to have this table and the records created on my remote server.  I tried saving the table in the Connections folder, but that didn't help.  Everytime I enter a code (valid or invalid) on the live site, I get the following message:  "Table 'boundsauctions_com.promocode' doesn't exist".  Is there someway to include the table and records in my Dreamweaver folders for the site? 
    Thanks for any help that you can offer.

    You can't.  Dreamweaver, or FTP for that matter has no connection to the MySQL database.  If you have created a MySQL database locally and now wish to move/copy it to your server you'll need to create a back up of your local database and then log into your database on the server and then restore that back up.
    An even easier way to do this, and if you are working with MySQL much at all  a good investement is to get the commercial version of Navicat MySQL - this is the best MySQL administrator I've found to date and is well worth the few bucks to buy it.  With Navicat you can connect to your local MySQL database and also create a connection to your remote database, then literally drag and drop your local database contents to copy them to your server. This function alone justifies buying Navicat. A huge time saver.   And no I do not work for or have any share or ties to Navicat.  I'd recommend something else if I knew of anything better, but so far I don't.
    Hope this helps. If you need any more details let me know.
    Lawrence Cramer - *Adobe Community Professional*
    http://www.Cartweaver.com
    Shopping Cart for Adobe Dreamweaver
    available in PHP, ColdFusion
    Stay updated - http://blog.cartweaver.com

  • Any difference between webdynpro for java and webdynpro for abap ?

    Hi all:
       I would like to build one small system in EP.
       I can choose to use webdynpro for java and webdynpro for abap.
       I would like to ask any major difference between webdynpro for abap and webdynpro for java ?
       Is fpm supported in webdynpro for abap ?

    Hi,
    see this thread,
    ABAP Vs JAVA WebDynpro
    Regads,
    J.Joe

  • Problems between Xcelsius and WebDynpro for Java

    How should I do to show Xcelsius in WebDynpro for Java?
    How should I transport data between Xcelsius and WebDynpro?
    How should I control WebDynpro with Xcelsius?For example,firing plugs in Xcelsius like in WebDynpro to change one view to another.
    How should I do to execute a Java method in Xcelsius?For example,scheduling a job on clicking a button in Xcelsius.
    Besides these,I also want to know the same problems between other BOE contents and WebDynpro for Java.
    Regards,
    Abe

    Hi Pradeep:
    Well that purely depends on the business application (project) your client is proposing. Following are very few factors which will drive for creating web-based applications:
    VC: it's a UI modeling tool (non-programming) for creating rapid creation of web-based applications.
    WD: its a powered by Java and ABAP with which you can create robust business applications.
    If your client is very choosy about rapid application development, reporting, rich user interface, to reduce TCO then VC is the choice. Or if the project contains typical integration with SAP and non-SAP systems, complex business logic development, integration with WCM systems...etc then WDJ is the option.
    If you’ve some sort of custom development with facilitating the Development Infrastructure (NWDI) then WDJ is the only option I could say.
    We hope with NW CE 7.1.1(referred by Priyanka Singh) tighter integration between these TWO tools may over come the ambiguity of using them.
    Tnx,
    MS

Maybe you are looking for