Hi All
Thanks for Prompt Response from Community
I am finally able to resolve this issue. Rather than using JDBC Driver Class I have used another Class available which is DB2SimpleDataSource. This has allowed me to get Connection to already running Database. Once we get Connection we can use SQL to get Data from Table.
public static javax.sql.DataSource getDS(String database, String user, String password) throws SQLException
{
com.ibm.db2.jcc.DB2SimpleDataSource ds = new com.ibm.db2.jcc.DB2SimpleDataSource();
// DatabaseName can include Cloudscape URL Attributes
ds.setDatabaseName(database);
if (user != null)
ds.setUser(user);
if (password != null)
ds.setPassword(password);
// The host on which network server is running
ds.setServerName("localhost");
// port on which Network Server is listening
ds.setPortNumber(1527);
// Driver type must be 4 to access Network Server
ds.setDriverType(4);
return ds;
}
Access the Database using:
javax.sql.DataSource ds = getDS("c:/temp/TESTDB", null, null);
// Note: user and password are required on connection
conn = ds.getConnection("ddd", "dd");
Thanks and Regards
------------------------------------------------------------------------------------------------------------------
Kapil Bajaj
India Software Labs
IBM Software Group.
Email : [EMAIL PROTECTED]
| Michael Koester <[EMAIL PROTECTED]>
03/31/2005 11:15 PM
|
|
You might include db2jcc_license_c.jar as well into the classpath.
Michael
Shreyas Kaushik
<Shreyas.Kaushik@
Sun.COM> To
Derby Discussion
31.03.2005 18:36 <[email protected]>
cc
Please respond to Subject
"Derby Re: Urgent Help Required :
Discussion" Accessing DB with Derby Net Server
What is the error message you get? Details would help ...
~ Shreyas
Kapil Bajaj wrote:
>
> Hi All
>
> I am trying to read a table from Cloudscape Database using Derby Net
> Server through Java Program
>
> Every Time I run program I get the Error "No Suitable Driver"
>
> Here is portion from Java Program
>
> Connection connection = null;
> Driver driver = null;
> String s = "jdbc:derby:net://localhost:1527/TEST;";
> try
> {
> driver =
> (Driver)Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
> }
> catch(Exception exception)
> {
> System.out.println("1");
> exception.printStackTrace();
> }
> try
> {
> DriverManager.registerDriver(driver);
> connection = DriverManager.getConnection(s, "", "");
> }
> catch(Exception exception1)
> {
> System.out.println("2");
> exception1.printStackTrace();
> }
>
> I have made sure that db2jcc.jar is included in Classpath. I have not
> downloaded any jar File only used what is available in Cloudscape By
> Default.
>
> My Cloudscape Server is running and I wanted to take connection from
> running Server without Stopping Server. Also I am setting
> derby.system.home Property to location in C Drive using -D Option
> while running Java File. I am setting system.home Property to
> Directory where my database is residing.
>
> However if I use Embedded Driver DB2jDriver than my program works fine
> but I am getting Error with Network Server Mode.
>
> Please help me with this issue as this is really urgent.
>
> Thanks and Regards
>
------------------------------------------------------------------------------------------------------------------
> Kapil Bajaj
