jndi

How to retrieve DB connection using DataSource without JNDI?

ぃ、小莉子 提交于 2019-12-01 09:01:44
问题 We want our own db connection configuration instead of using JNDI, but in the meantime, we also want to use DataSource instead of using DriverManager, how to do so? 回答1: You use a connection pool library like c3p0 or commons dbcp. C3P0 ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDriverClass( "org.postgresql.Driver" ); //loads the jdbc driver cpds.setJdbcUrl( "jdbc:postgresql://localhost/testdb" ); cpds.setUser("dbuser"); cpds.setPassword("dbpassword"); Connection

problem configure JBoss to work with JNDI

一曲冷凌霜 提交于 2019-12-01 08:36:48
I am trying to bind connection to the DB using JNDI in my application that runs on JBoss. I did the following: I created the datasource file oracle-ds.xml filled it with the relevant xml elements: <datasources> <local-tx-datasource> <jndi-name>bilby</jndi-name> ... </local-tx-datasource> </datasources> and put it in the folder \server\default\deploy Added the relevant oracle jar file than in my application I performed: JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName("bilby"); try{ factory.afterPropertiesSet(); dataSource = factory.getObject(); } catch

【J2EE系列】JNDI与tomcat连接池

一曲冷凌霜 提交于 2019-12-01 07:32:06
JNDI 与tomcat连接池 本章内容 ² JNDI与JNDI服务器 ² 编码实现JNDI目录服务与命名服务 ² 使用Tomcate JNDI服务器 一、JNDI概述 1、 什么是JNDI? 英文全称是:Java Naming and Directory Interface 命名服务提供了一种为对象命名的机制,这样你就可以在无需知道对象位置的情况下获取和使用对象。只要该对象在命名服务器上注册过,且你必须知道命名服务器的地址和该对象在命名服务器上注册的JNDI名。就可以找到该对象,获得其引用,从而运用它提供的服务。 利用JNDI可以寻找在命名服务器上注册过的所有对象。 JNDI就是为JAVA中命名和目录服务定义的JAVA API,是命名服务的抽象机制。我们可以直接通过JNDI来操作命名服务,而不要与底层的命名服务器交互,大大减轻了程序员的压力。 2、什么是JNDI server? 能提供目录或命名服务的服务器,相当于数据库。 常见JNDI服务器:DNS、XNam 、Novell目录服务、 LDAP(Lightweight Directory Access Protocol 轻型目录访问协议)、 CORBA对象服务、 Tomcat数据源 EJB容器的Bean对象(通过jdni技术访问) 文件系统、 Windows XP/2000/NT/Me/9x的注册表、 RMI、DSML v1

Cannot instantiate InitialContext with JBoss server

旧街凉风 提交于 2019-12-01 06:44:51
I'm trying to create a InitialContext so I could ask the JNDI for some enterprise java beans. The JBoss is running fine, but when I run the java code I get an exception. I'm running JBoss 7.1 Here is my code: public class Test { public static void main(String[] args){ InitialContext ctx=getInitialContext(); Object ref=null; try { ref = ctx.lookup("ParamEJB/remote"); } catch (NamingException e) { System.out.println("Lookup Failed"); e.printStackTrace(); } Param stub=(Param)PortableRemoteObject.narrow(ref, Param.class); int times=stub.getTimes(); for(int i=0;i<times;i++) System.out.println(stub

Cannot instantiate InitialContext with JBoss server

倖福魔咒の 提交于 2019-12-01 05:29:27
问题 I'm trying to create a InitialContext so I could ask the JNDI for some enterprise java beans. The JBoss is running fine, but when I run the java code I get an exception. I'm running JBoss 7.1 Here is my code: public class Test { public static void main(String[] args){ InitialContext ctx=getInitialContext(); Object ref=null; try { ref = ctx.lookup("ParamEJB/remote"); } catch (NamingException e) { System.out.println("Lookup Failed"); e.printStackTrace(); } Param stub=(Param)PortableRemoteObject

apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc]

瘦欲@ 提交于 2019-12-01 04:37:10
let me describe the environment first: environment: - mac os x (java build 1.6.0_35-b10-428-11M3811) - apache tomcat 7.0.30 - mysql 5.5.27 - tomcat/lib --> mysql-connector-java-5.1.22-bin.jar i've implemented successfully a JDBCRealm and want to switch to a DataSourceRealm because it is recommended for production environments. i use form-based authentication. I did everything described here: http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm and here: http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example server.xml <Realm className

Should I close JNDI-obtained data source?

浪子不回头ぞ 提交于 2019-12-01 03:58:39
Update: Apparently Tomcat, starting with 7.0.11, closes the DataSource for you, so it's not available in the webapp's contextDestroyed. See: https://issues.apache.org/bugzilla/show_bug.cgi?id=25060 Hi, I'm using Spring 3.0 and Java 1.6. If I get a data source this way: <bean id="dataSource" class="my.data.Source" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@localhost:1521:home"/> <property name="username" value="user"/> <property name="password" value="pw"/> </bean> then the data source is

apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc]

做~自己de王妃 提交于 2019-12-01 01:54:45
问题 let me describe the environment first: environment: - mac os x (java build 1.6.0_35-b10-428-11M3811) - apache tomcat 7.0.30 - mysql 5.5.27 - tomcat/lib --> mysql-connector-java-5.1.22-bin.jar i've implemented successfully a JDBCRealm and want to switch to a DataSourceRealm because it is recommended for production environments. i use form-based authentication. I did everything described here: http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm and here: http://tomcat

HTTP 500 - Cannot create JDBC driver of class '' for connect URL 'null'

血红的双手。 提交于 2019-12-01 01:13:45
I have been searching to fix that problem for 3 days reading forums... Then I decided to ask for some help. Nedless to say that your help would be highly appreciated :-) I created a jndi resource for the mysql connexion in Tomcat context.xml instance in Eclipse My web app works fine when I start the server from eclipse. It doesn't work fine when I start the web app from eclipse 'Run configurations' with that goals : clean tomcat7:run. My aim is to delegate the build, deploy, start server to maven from eclipse. I've put the mysql-connector-java-5.1.27.jar in Tomcat_Home/lib. I don't want to put

Associate Ldap user to a group with Java

女生的网名这么多〃 提交于 2019-11-30 20:55:58
I'm having problems to find how to associate a #Ldap user to a given group. That is what I have tried: Attributes attrs = new BasicAttributes(); BasicAttribute basicAttrs = new BasicAttribute("objectclass"); basicAttrs.add("top"); basicAttrs.add("person"); BasicAttribute memberOf = new BasicAttribute("memberOf"); memberOf.add("Managers"); // Tried with distinguished name too memberOf.add("Administrators"); // Tried with distinguished name too attrs.put(basicAttrs); attrs.put("cn", user.getLogin()); attrs.put("name", user.getLogin()); attrs.put("login", user.getLogin()); attrs.put("mail", user