DB中的Java类 [英] Java class in DB

查看:103
本文介绍了DB中的Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释为什么将Java类存储在Db中的想法吗?这有什么用?以及如何使用Java类创建存储过程?

Can anyone explain why was idea to store Java class in Db? What it is good for? And how to create stored procedure with Java class?

最诚挚的问候!

推荐答案

Oracle在版本8i中将存储过程引入了其数据库. i 代表互联网",就像互联网就绪"一样,这基本上是一种营销.但是Java存储过程允许Oracle通过利用大量可用的Java库来极大地扩展数据库中可用的功能范围. Oracle 8i中的许多新数据库功能是Java库的PL/SQL包装,尤其是XML.

Oracle introduced stored procedures into their database in release 8i. The i stood for "internet", as in "internet-ready", which basically was a bit of marketing. But Java Stored Procedures allowed Oracle to extend the range of functionality available in the database queite dramatically, by leveraging the vast amount of Java libraries available. A lot of the new database functionality in Oracle 8i was PL/SQL wrappers of Java libraries, notably the XML stuff.

Oracle显着地将许多功能重写到Oracle 9的本机C中,因为它的运行速度比包装的Java东西快得多.我知道,喜欢那个.

Significantly Oracle re-wrote a lot of that functionality into native C in Oracle 9, because it ran a lot faster than the wrapped Java stuff. I know, fancy that.

对我们来说,什么时候使用Java存储过程有意义?基本上,当Java提供某些功能时,本机数据库语言不提供这些功能.例如,我编写了JSP来包装ICE Syslog Java类,因此我的PL/SQL日志记录例程可以写入syslog文件.这表明了Java的一个非常普遍的用例-将数据库应用程序的范围扩展到OS中. JSP的最常见用法是编写host命令,该命令允许PL/SQL程序激发外部可执行文件.

For us, when does it make sense to use Java Stored Procedures? Basically, when there features available in Java which are not available in the native database language. For instance, I have written JSPs to wrapper the ICE Syslog java classes, so my PL/SQL logging routines can write to syslog files. This indicates a very common use case for Java - extending the reach of our database applications into the OS. Perhaps the most common use of a JSP is to write a host command which allows a PL/SQL program to fire an external executable.

我认识到一些写JSP的开发人员,因为他们了解Java并且不想学习PL/SQL.这不够好,有两个原因:

I know some developers who write JSPs because they know Java and don't want to learn PL/SQL. This is not good enough for two reason:

  1. 使用内置组件总比重新发明轮子要好
  2. 正如我已经提到的,数据库中的Java的性能不如本地代码.

当然,如果您正在苦苦研究必须与几种不同的数据库产品一起运行的产品,那么Java的跨平台适应性将非常吸引人.当涉及到过程语言(T-SQL与PL/SQL等)时,DBMS的不同风格差异最大,因为与SQL不同,它没有标准.

Of course, if you are wroking on a product which has to run against several different database products, then Java's cross-platform adaptability is very appealing. The different flavours of DBMS are most divergent when it comes to their procedural languages (T-SQL vs PL/SQL, etc) because there is no standard for it, unlike SQL.

如果您想了解有关在Oracle中编写JSP的信息,请

If you want to learn about writing JSPs in Oracle, the online documentation is a good place to start. If it turns out you are using a different database rather than Oracle, well I'm sure that product has its own equally fine manual.

这篇关于DB中的Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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