1998 International Sybase User Group North American Conference 1998 International Sybase User Group North American Conference Options For Connecting Java Applets To Sybase Options For Connecting Java Applets To Sybase u Gunther Birznieks u National Human Genome Research Institute
89
Embed
Options For Connecting Java Applets To Sybase - · PDF fileOptions For Connecting Java Applets To Sybase Options For Connecting Java Applets To Sybase uGunther Birznieks ... uMatching
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Options For Connecting Java Applets ToSybaseOptions For Connecting Java Applets ToSybase
u GuntherBirznieks
u NationalHumanGenomeResearchInstitute
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Connecting Java Applets To SybaseConnecting Java Applets To Sybase
u “If I had a dime… ”u JDBC is frequently not the whole solution!u There are many different ways to connect
applets to Sybase.
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
It’s About ArchitectureIt’s About Architecture
u Architecture evolvesu New technology with existing infrastructureu Seek out strategic new technologiesu Java, CORBA, and moreu But do not blindly throw away old technologyu Try to leverage the old with the newu Recognize the tradeoffs
u “The Problem With Standards Is That There Are So Many!"
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Options To Connect Applets To SybaseOptions To Connect Applets To Sybase
u JDBC (Java DataBase Connectivity)u Straight-up/JSQLu JavaBlend
public class SampleCode { public static void main(String args[]) { try { Connection con = DriverManager.getConnection("jdbc:sybase:Tds:myserver:3767", "sa", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select 1");
if (rs != null) && (rs.next()) { int value = rs.getInt(1); System.out.println("Fetched value " + value); } } catch (SQLException sqe) { System.out.println(”Exception : " + sqe.toString() + ", sqlstate = " + sqe.getSQLState()); System.exit(1); } // End of Exception Handler System.exit(0); } // End of main} // End of SampleCode
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Securityu Low if password to database embedded in appletu Low if password transmitted without SSL
u Firewall Compatibilityu Good on the client-side since HTTP Tunneling is
automaticu Can be bad on the server sideu Point of vulnerabilityu Open your Sybase server directly to the world?
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Java Applet Sizeu OK for simple appletsu Bad for complicated appletsu Application logic will tend to get located on the
applet side
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Browser Compatibilityu Bad for large JDBC applets (with business logic in
the applet)u More class library inclusion on the browser
side means more compatibility quirks to dealwith
u Good for actual connectivity thoughu Native JDBC Library can be downloadedu Connection to gateway on original Web Serveru Java Security Model (IP address restriction)
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Network Bandwidth (Internet/Intranet)u Good because TDS (tabular data stream) is faster
than HTTPu Internet Exceptionu HTTP Tunneling
u Can be worse as applet size increasesu Increase in client-side application logicu Followed by increase in raw data processed by
client
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Ease of Development/Maintenanceu Easy if familiar with CLI Architecturesu Call Level Interfaces - CT-Lib, DB-Lib
u Ease of maintenance can be highu With loosely coupled architectureu Data access abstracted away from
presentation/application logic
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Matching Current Software Architectureu Advantageu If you are already developing 2-tier Sybase
applicationsu Disadvantageu If you are coding too much application logic
client-sideu Your developers may be used to languages
other than Java
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Software Reuseu Reuse is low if application logic is stored client-
sideu Applet is relatively self-containedu Although stored on central web server, still
compiled as a separate entity
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
JDBC ConsiderationsJDBC Considerations
u Internet vs Intranet (Controlled Deployment)u Internetu Good client compatibilityu Firewallu JDBC Library compatible
u Intranet - JDBC is better hereu Greater bandwidth lowers impact of fat appletsu Security (firewall, password) is not as much of
a problemu Caveat - Your business may want to open an
Intranet application up to the Internet!
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
2 or 3-Tier Solution - Sockets2 or 3-Tier Solution - Sockets
u Proprietary solutionsu Build your own protocol over TCP/IPu Clientu Serveru Middleware Application serveru Gateway to Sybase
u Proprietary does not necessarily mean bad!
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Securityu Generally badu Proprietary protocol incompatible with
firewallsu Higher complexity = possible security holes
u Could be good if it cannot be interpreted byothers
u But beware...u Java decompilersu Home grown protocol security may not be as
clever as you think
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Firewall Compatibilityu Bad -- No commercial firewall support for
proprietary proxy serversu Java Applet Sizeu The complexity of the protocol can increase
applet sizeu 3-Tier solution has better code size
u Browser Compatibilityu Good because all Java browsers support socketsu Bad if code bloat ends up increasing applet size
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Network Bandwidth (Internet/Intranet)u Excellent if protocol tuned for performanceu Made worse if used in a gateway rather than
application server manner
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Ease of Development/Maintenanceu Protocol development is hardu Maintenance tends to be difficultu What if your protocol programmer leaves?u What if your protocol changes?
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Matching Current Software Architectureu Good if protocol is in use in other programs such
as C++u Software Reuseu Proprietary protocols tend to be difficultu Too easy to add “1 more new feature”u Some “new features” could break old ones
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Sockets ConsiderationsSockets Considerations
u Internet vs Intranet (Controlled Deployment)u Internetu Can be excellent with a tuned protocolu Beware of applet bloating
u Intranetu Generally bad to use for limited deploymentu Reuse/maintenance problem baggage
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Object Middleware - RMIObject Middleware - RMI
u Remote Method Invocationu Java only for both client and serveru Except for superior Java support, fairly
sparse standardu Very little securityu Naming services (JNDI, JavaSpaces soon)u Proprietary Protocol (Eventually IIOP)
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
u Ease of Development/Maintenanceu CORBA, DCOM generally hard to developu CORBA standard alone is several hundred pagesu Usually need to learn an Interface Definition
Language (IDL)u Netscape/Visigenic Caffeine
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
u Ease of Developmentu Object Oriented Analysis and Designu Uses well-established “Design Patterns”u Factory for creating new objectsu Proxy objects for managing remote objects
u Referenceu “Design Patterns” by the “gang of four”u Erich Gamma, Richard Helm, Ralph Johnson,
John Vlissidesu 1995, Addison-Wesley
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
u Maintenanceu Easier if object model is correctu Just unload old object and reload new oneu Object model not always correctu requires retooling many objects
u Rule of Thumb: Use object middleware primarilyfor well defined enterprise interfaces or large-scale distributed systems
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
u Basically the same as Object Middlewareu Advantagesu Transaction-aware objects are important in
database connectivityu Disadvantagesu Less openu Look for Java EnterpriseBeans Solution
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server MiddlewareWeb Server Middleware
u HTTP Compatible protocolu Simply POST data to Web Serveru Web Server processes data and returns it as
a web documentu Java Applet parses the web responseu JavaCGIBridgeu http://www.extropia.com/Scripts/
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - DiagramWeb Server Middleware - Diagram
DatabaseServer
JavaCGIBridge
Web.SQLServletCGI/Perl
Java Applet GUI
Flat File onWeb Server
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u JavaCGIBridge exampleu Modify CGI/Perl programs to return parsed datau Add JavaCGIBridge class to Java applet
implementation
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u Data to be returned should be identifiedu Top separator (<!--start of data-->)u Bottom Separator (<!--end of data-->)u Pipe delimited fieldsu (Optional) Set up form variable to tell script to
send data using separators defined above(javacgibridge=on)
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u The code on the next slide shows how aCGI/Perl or WEB.SQL application would bemodified to return sample data for the Javaapplet if the form variable “javacgibridge” isset to “on”.
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
# If javacgibridge is on, send data specially formatted for# java applet, otherwise send regular HTML data to the user’s browserIf ($form_data{“javacgibridge”} eq “on”) { print “<!--start of data-->”; # Loop through data here while (@row_of_data = &getRowOfData()) { printf(“%s|%s|\n”,@row_of_data); } print “<!--end of data-->”;} else { print “<TABLE><TR><TH>Last Name</TH><TH>First Name</TH></TR>”;
# Loop through data here while (@row_of_data = &getRowOfData()) { printf(“<TR><TD>%s</TD><TD>%s</TD></TR>\n”, @row_of_data); } print “</TABLE>”;}
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u Instantiate JavaCGIBridge classu Set up form variable, form value pairs inside
Hashtableu Set up URL by instantiating URL classu Get parsed data back using the URL and form
variable Hashtable as a Vector of Vectors
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u Sample Java Codeu The code on the next slide calls Address Book
search script setting “firstname” and“javacgibridge” HTML form variables. Therecords will be returned as a Vector containing allthe fields in each record as a Vector of Strings.
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
URL u = new URL("http://www.yourdomain.com/cgi-bin/address_query.cgi");
JavaCGIBridge jcBridge = new JavaCGIBridge();
// firstNameTextField is a text field on a Java applet that the user fills // in to query.jcBridge.addFormValue(formVars,"firstname",firstNameTextField.getText());jcBridge.addFormValue(formVars,"javacgibridge", "on"); Vector addressBookResults = jcBridge.getParsedData(u,formVars);
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware - Nuts and BoltsWeb Server Middleware - Nuts and Bolts
u All searchdata ANDmodificationcode on ONEapplet
u But alsoincludesnormal HTMLinterface
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Securityu Excellentu SSL may be used to encrypt both passwords
AND datau Database passwords can be kept on the web
server sideu Firewall proxys are compatible with HTTP and
SSL protocolsu Firewall Compatibilityu Excellent Proxy Support for HTTP protocol
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Java Applet sizeu Goodu Application logic is stored on the server sideu JavaCGIBridge < 7k
u Browser Compatibilityu Goodu Applets kept smaller with logic on the web
serveru CGI Bridge takes advantage of built in class
librariesu URL, URLConnection classes
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Network Bandwidth (Internet/Intranet)u Goodu Applets kept smallu Application logic layer can preprocess
database result set
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Ease of Development/Maintenanceu Development is easieru Leverage existing web server CGI codeu Leverage existing programmer knowledge
about CGIu Maintenanceu Easier since application logic is on a middle
tieru Not as easy as Object/Transaction middlewareu But weakly typed CGI protocol makes
changes easier to implement
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Matching Current Software Architectureu Great if your company is already developing CGIu Solves Java client-side compatibility problemsu Provide clients with forms interface for core
functionsu Use Java for enhancements as optional
functions
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Software Reuseu Great if already developing CGIu Generally worse than existing object
infrastructures such as CORBA if CGI is not anexisting or intended architecture
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Web Server Middleware ConsiderationsWeb Server Middleware Considerations
u Internet vs Intranet (Controlled Deployment)u Intranetu Utilize web server access control features
inside Java appletsu Internetu Good use because HTTP is a standard Internet
protocolu Very few browser incompatibilities
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u JDBCu Socketsu Object Middlewareu Object Transaction Middlewareu Web Server Middleware
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u JDBCu Prosu Directly integrated to Sybaseu Performance with TDS is goodu CT-Lib developers will find transition easy
u Consu Security for both password and data (use SSL)u 2-Tier bloated applet problem
u Bottomlineu Useful for Intranetu Security/Fat code make it less ideal for Internet
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Socketsu Prosu High performance for tuned protocol
u Consu Protocol not usually seen by firewall proxysu Hard to develop/maintain
u Bottomlineu Useful for very specific performance oriented
applicationsu Only limited use on the open Internetu Large development shop that can afford to
develop its own infrastructure
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Object Middlewareu Prosu Common architecture for software reuseu CORBA is an open standard
u Consu Not much browser support yetu Difficult to work in some modelsu Some are Java onlyu CORBA and DCOM are difficult to learn
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Object Middleware Bottomlineu For companies with no central architecture
development, object middleware can speed youon the road to reuse
u Need to invest in trainingu Not necessarily for use in projects that are
constantly changingu as opposed to evolving
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Transaction Middlewareu Prosu Very database orientedu Transactions managed for youu Security is good in most cases
u Consu Generally proprietaryu May change with EnterpriseBeans spec
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Transaction Middleware Bottomlineu Jaguar CTS is great for shops already used to
Sybase developmentu Microsoft MTS is relatively closed to all except
DCOMu Useful 1-vendor solution for Microsoft shops
u Java Enterprise Beansu Jaguar CTS may comply with the standard as
an added plusu Start managing enterprise objects for reuse
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Web Server Middlewareu Prosu Security of both data and password handled
through HTTPSu Middleware handles database access in
familiar languageu Consu Weakly typedu HTTP can be slow protocolu CGI Invocations are typically slowu Can be sped up with the use of Web.SQL,
servlets, ASP, mod_perl techniques
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
Solutions SummarySolutions Summary
u Web Server Middleware Bottomlineu Great if you have a lot ofu Perl or Web.SQLu Active Server Pages (Microsoft)u Cold Fusionu Servletsu Other CGI-Like interfaces
u Excellent way to leverage your code andprogrammer expertise
u Also, useful for applets on the Internetu HTTP is a totally open standard
1998 International Sybase User Group North American Conference1998 International Sybase User Group North American Conference
More Information…
u Visit http://www.extropia.com/Scripts/uFurther information on this talkuJavaCGIBridge class examples and
source codeu AcknowledgementsuPeter Chines, Joseph Ryan, Erik Ferlanti,