dcsimg
Pls help me!! How to Register a DataSource with JNDI
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sujith_Varghese
Posted On:   Monday, May 20, 2002 10:28 PM

Hi How to Register a DataSource with JNDI I am using this code but an error is occured. import javax.sql.*; import java.sql.*; import javax.naming.*; public class dataSource { public static void main(String s[]) { new dataSource(); } public dataSource() { try { com.microsoft.jdbcx.sqlserver.SQLServerDataSource datasource=new com.microsoft.jdbcx.sqlserver.SQLServerDataSource(); datasource.setServerName("localhost"); datasource.setDatabaseName(&quo   More>>

Hi

How to Register a DataSource with JNDI
I am using this code but an error is occured.



import javax.sql.*;

import java.sql.*;

import javax.naming.*;



public class dataSource

{

public static void main(String s[])

{

new dataSource();

}

public dataSource()

{

try

{



com.microsoft.jdbcx.sqlserver.SQLServerDataSource datasource=new com.microsoft.jdbcx.sqlserver.SQLServerDataSource();

datasource.setServerName("localhost");

datasource.setDatabaseName("Test");

Context env = (Context) new InitialContext();

env.bind("jdbc/TestDB",datasource);

}

catch(Exception e){System.out.println(e);}

}

}







The error is

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial



Thanks


Sujith Varggese

Please insert a sample code

   <<Less
About | Sitemap | Contact