diff options
author | Ocke.Janssen <Ocke.Janssen@oracle.com> | 2010-11-04 14:56:15 +0100 |
---|---|---|
committer | Ocke.Janssen <Ocke.Janssen@oracle.com> | 2010-11-04 14:56:15 +0100 |
commit | 5afd753bffcebaf4e6d75ae72a0145cb95e0846a (patch) | |
tree | ab56893d72ab566f51d1bb8de8c1493e891eb426 /odk/examples | |
parent | Automated merge with http://hg.services.openoffice.org/cws/dba34b (diff) | |
download | core-5afd753bffcebaf4e6d75ae72a0145cb95e0846a.tar.gz core-5afd753bffcebaf4e6d75ae72a0145cb95e0846a.zip |
dba34b: #i106807# use mysql instead of adabas now
Diffstat (limited to 'odk/examples')
-rw-r--r-- | odk/examples/DevelopersGuide/Database/CodeSamples.java | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/odk/examples/DevelopersGuide/Database/CodeSamples.java b/odk/examples/DevelopersGuide/Database/CodeSamples.java index 79b3405a4602..994e6e4f9b3d 100644 --- a/odk/examples/DevelopersGuide/Database/CodeSamples.java +++ b/odk/examples/DevelopersGuide/Database/CodeSamples.java @@ -151,33 +151,6 @@ public class CodeSamples if(xDriverManager != null) { // first create the needed url - String adabasURL = "sdbc:adabas::MYDB0"; - // second create the necessary properties - com.sun.star.beans.PropertyValue [] adabasProps = new com.sun.star.beans.PropertyValue[] - { - new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE), - new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE) - }; - // now create a connection to adabas - con = xDriverManager.getConnectionWithInfo(adabasURL,adabasProps); - } - return con; - } - - // uses the driver manager to create a new connection and dispose it. - public static XConnection openToJDBC() throws com.sun.star.uno.Exception - { - XConnection con = null; - // create the DriverManager - Object driverManager = - xMCF.createInstanceWithContext("com.sun.star.sdbc.DriverManager", - xContext); - // query for the interface - com.sun.star.sdbc.XDriverManager xDriverManager; - xDriverManager = (XDriverManager)UnoRuntime.queryInterface(XDriverManager.class,driverManager); - if(xDriverManager != null) - { - // first create the needed url String url = "jdbc:mysql://localhost:3306/TestTables"; // second create the necessary properties com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[] @@ -186,7 +159,7 @@ public class CodeSamples new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE), new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE) }; - // now create a connection to adabas + // now create a connection to mysql con = xDriverManager.getConnectionWithInfo(url,props); } return con; @@ -198,7 +171,7 @@ public class CodeSamples XConnection con = null; // create the Driver with the implementation name Object aDriver = - xMCF.createInstanceWithContext("com.sun.star.comp.sdbcx.adabas.ODriver", + xMCF.createInstanceWithContext("org.openoffice.comp.drivers.MySQL.Driver", xContext); // query for the interface com.sun.star.sdbc.XDriver xDriver; @@ -206,15 +179,16 @@ public class CodeSamples if(xDriver != null) { // first create the needed url - String adabasURL = "sdbc:adabas::MYDB0"; + String url = "jdbc:mysql://localhost:3306/TestTables"; // second create the necessary properties - com.sun.star.beans.PropertyValue [] adabasProps = new com.sun.star.beans.PropertyValue[] + com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[] { new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE), - new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE) + new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE), + new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE) }; - // now create a connection to adabas - con = xDriver.connect(adabasURL,adabasProps); + // now create a connection to mysql + con = xDriver.connect(url,props); } return con; } |