JDBCRealm和DataSourceRealm有什么区别? [英] What is the difference between JDBCRealm and DataSourceRealm?

查看:196
本文介绍了JDBCRealm和DataSourceRealm有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到此评论:根本不使用JDBCRealm:因为所有数据库通信都使用一个JDBC Connection对象,所以它根本不扩展.最好使用DataSourceRealm"

I read this comment: "don't use JDBCRealm at all: it does not scale at all since there is a single JDBC Connection object used for all database communication. You are better off using DataSourceRealm"

更详细的含义是什么?

推荐答案

如果您不知道为什么和什么领域-JAVA Web应用程序,则可以由应用程序或容器处理身份验证和授权( Tomcat等).如果选择使用该容器,则需要指定一个用户存储(存储用户名,希望加密的密码,角色等的位置).如果是Tomcat,这甚至可能是您的tomcat-users xml.或者,您可以使用数据库(MYSQL等)或目录(Active Directory等). Tomcat使用JDBC(您的JDBC领域)连接到数据库,并使用JNDI(您的DataSourceRealm)连接到目录.

Incase you don't know about why and what realms are- for JAVA web applications, authentication and authorization can be handled either by the application or by the container(Tomcat etc.). If one chooses to use the container, you need to specify a user-store(a place where usernames,hopefully encrypted passwords, roles etc are stored). This could even be your tomcat-users xml incase of Tomcat. Or you could use a database(MYSQL etc.) or a directory(Active Directory etc.) . Tomcat connects to the database using JDBC(your JDBC realm) and to the directory using JNDI(your DataSourceRealm).

您的问题来了,JDBC连接昂贵,有池限制并遭受高度同步,这意味着在高负载应用程序中,由于JDBC不可用,某些请求的身份验证可能会失败. JNDI具有更好的池化功能,可以优化读取,因此具有更好的性能.

Coming to your question JDBC connections are expensive, have pooling limitations, and suffer from high synchronization which means in a high load application, authentication may fail for some requests due to unavailability JDBC. JNDI has better pooling being read optimized, and as such gives better performance.

这篇关于JDBCRealm和DataSourceRealm有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆