<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://petersap.nl/SybaseWiki/index.php?action=history&amp;feed=atom&amp;title=User_defined_Java_functions</id>
		<title>User defined Java functions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://petersap.nl/SybaseWiki/index.php?action=history&amp;feed=atom&amp;title=User_defined_Java_functions"/>
		<link rel="alternate" type="text/html" href="http://petersap.nl/SybaseWiki/index.php?title=User_defined_Java_functions&amp;action=history"/>
		<updated>2026-04-04T18:47:33Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>http://petersap.nl/SybaseWiki/index.php?title=User_defined_Java_functions&amp;diff=1700&amp;oldid=prev</id>
		<title>Psap at 22:18, 6 July 2007</title>
		<link rel="alternate" type="text/html" href="http://petersap.nl/SybaseWiki/index.php?title=User_defined_Java_functions&amp;diff=1700&amp;oldid=prev"/>
				<updated>2007-07-06T22:18:05Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:18, 6 July 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 56:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 56:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Luckily you can still download this version from the archives at sun: http://java.sun.com/products/archive/j2se/1.2.2_017/index.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Luckily you can still download this version from the archives at sun: http://java.sun.com/products/archive/j2se/1.2.2_017/index.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This issue raises some doubts if Sybase is still really committed to this functionality. Talk to your local customer support center to get more background info on this issue.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This issue raises some doubts if Sybase is still really committed to this functionality. Talk to your local customer support center to get more background info on this issue.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:ASE]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key website-mw_:diff:version:1.11a:oldid:1699:newid:1700 --&gt;
&lt;/table&gt;</summary>
		<author><name>Psap</name></author>	</entry>

	<entry>
		<id>http://petersap.nl/SybaseWiki/index.php?title=User_defined_Java_functions&amp;diff=1699&amp;oldid=prev</id>
		<title>Psap at 22:17, 6 July 2007</title>
		<link rel="alternate" type="text/html" href="http://petersap.nl/SybaseWiki/index.php?title=User_defined_Java_functions&amp;diff=1699&amp;oldid=prev"/>
				<updated>2007-07-06T22:17:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Java classes can be stored within ASE and be used as functions accessible from T-SQL. This document shows how to enable Java in ASE, create a sample class file, store it in the database and access it through a SQL statement.&lt;br /&gt;
==Configuration of Java in ASE==&lt;br /&gt;
Enable Java in ASE with sp_configure.&lt;br /&gt;
 sp_configure &amp;quot;enable java&amp;quot;,1&lt;br /&gt;
Reboot the server, it's a static setting.&lt;br /&gt;
==Create a Java class==&lt;br /&gt;
In this example a java class is created that retrieves the hostname of an (internet)server when the ip-address is supplied.&lt;br /&gt;
 import  java.net.InetAddress;&lt;br /&gt;
 import  java.net.UnknownHostException;&lt;br /&gt;
 &lt;br /&gt;
 public class HostName&lt;br /&gt;
 {&lt;br /&gt;
    public static String get(String ipaddress)&lt;br /&gt;
    {&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            return  InetAddress.getByName(ipaddress).getHostName();&lt;br /&gt;
        }&lt;br /&gt;
        catch (UnknownHostException e)&lt;br /&gt;
        {&lt;br /&gt;
            return  null;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Compile the java file==&lt;br /&gt;
 javac HostName.java&lt;br /&gt;
==Store the class in the database==&lt;br /&gt;
Store the class file in a jar file. ASE can only accept jar files. When you try to store class files you will see this error:&lt;br /&gt;
 Server Message: ASE1 - Msg 10728, Level 16, State 1:&lt;br /&gt;
 The specified file or image column contains a Java class. Java classes cannot be directly installed. Enclose this class in a jar and re-try your command.&lt;br /&gt;
&lt;br /&gt;
Create the jar file, it should be uncompressed.&lt;br /&gt;
 jar cf0 HostName.jar HostName.class&lt;br /&gt;
Store the jar file in the database&lt;br /&gt;
 installjava -f HostName.jar  -S&amp;lt;server&amp;gt; -U&amp;lt;username&amp;gt; -P&amp;lt;password&amp;gt; -D&amp;lt;database&amp;gt;&lt;br /&gt;
When the jar file is loaded into ASE each individual class is extracted from the jar file and stored under its own name.&lt;br /&gt;
==Use the java class==&lt;br /&gt;
Now you can use the java class:&lt;br /&gt;
 select HostName.get(&amp;quot;127.0.0.1&amp;quot;)&lt;br /&gt;
==Create a wrapper around the Java class==&lt;br /&gt;
You can create a wrapper about the java class in order to make the function more compatible with T-SQL.&lt;br /&gt;
 create function getHostName(ipaddress varchar(255))&lt;br /&gt;
 returns varchar(255)&lt;br /&gt;
 language java parameter style java external name &amp;quot;HostName.get(java.lang.String)&amp;quot;&lt;br /&gt;
Call the function like this&lt;br /&gt;
 select getHostName(&amp;quot;127.0.0.1&amp;quot;)&lt;br /&gt;
==Remove a java class from the database==&lt;br /&gt;
 remove java class HostName&lt;br /&gt;
==Use jdk 1.2.2==&lt;br /&gt;
You should compile the java source with the most old-fashioned java compiler around: version 1.2.2. When you use a more recent compiler you are able to store the jar file into the database, but at runtime you get this error:&lt;br /&gt;
 Msg 10707, Level 16, State 1:&lt;br /&gt;
 Server 'ASE1', Line 1:&lt;br /&gt;
 Unhandled Java Exception: &lt;br /&gt;
 java.lang.ClassFormatError: HostName&lt;br /&gt;
Luckily you can still download this version from the archives at sun: http://java.sun.com/products/archive/j2se/1.2.2_017/index.html&lt;br /&gt;
This issue raises some doubts if Sybase is still really committed to this functionality. Talk to your local customer support center to get more background info on this issue.&lt;/div&gt;</summary>
		<author><name>Psap</name></author>	</entry>

	</feed>