Knowing how powerful BeanShell really is I wanted to see if it can access databases (oracle). So I wrote quick and small script (real servers replaced of course ):
import java.sql.*; DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@my.oracle.server:1521:MYBASE", "user", "pass"); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION"); while (rset.next()) print (rset.getString(1)); // Print col 1 stmt.close();
I ran it and got:
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@my.oracle.server:1521:MYBASE
First idea was that it is a classpath problem (BeanShell can not access jdbc oracle driver) so I wrote another quickie to see what classpath BeanShell actually sees.
import java.net.URL; import java.net.URLClassLoader; ClassLoader = sysClassLoader = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader)sysClassLoader).getURLs(); for(int i=0; iAnd yes sure enough it could not see my oracle jdbc in classpath. So I did some testing and discovered that when running jEdit instead of
java -cp oracle.jar -jar jedit.jarlike thisjava -cp oracle.jar:jedit.jar org.gjt.sp.jedit.jEditthen BeanShell finds my oracle jdbc and classpath macro shows also oracle and database macro can connect to oracle server.
So I want to know if it somehow possible to specify classpath when running jEdit like it is usually ran (java -jar jedit.jar) or use some other methods (other than running jedit with org.gjt.sp.jedit.jEdit) to let BeanShell know my new classpath?
Keep up the good work,
Phade