Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArrayList: deprecation in comment. Miles2Kms: modernize, barely usable.
New: buildindex (for findJava), TypeMapDemo (tries and fails to use Type Map). Bye some old cruft.
- Loading branch information
Showing
12 changed files
with
270 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
err.log | ||
index-byname.html | ||
jabadot | ||
oreilly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<project name="Java Src Index" default="index" basedir="."> | ||
|
||
<!-- build and install the online index | ||
$Id$ | ||
--> | ||
|
||
<target name="index"> | ||
<ant dir="search" target="compile"/> | ||
<property name="lucene.jar" value="WEB-INF/lib/lucene-1.3-dev1.jar" /> | ||
<java classname="Indexer" classpath="search:${lucene.jar}" /> | ||
<mkdir dir="WEB-INF/index"/> <!-- ensure it there for robuse move --> | ||
<move todir="WEB-INF/index.bak"> | ||
<fileset dir="WEB-INF/index"/> | ||
</move> | ||
<move todir="WEB-INF/index"> | ||
<fileset dir="index"/> | ||
</move> | ||
<delete dir="WEB-INF/index.bak"/> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import java.sql.*; | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
* Following up on the javadoc for java.sql.Connection, | ||
* make a TypeMap that maps a *structured* UDT into a | ||
* MusicRecording "automatically". | ||
* @author Ian Darwin | ||
*/ | ||
public class TypeMapDemo { | ||
public static void main(String[] args) | ||
throws IOException, ClassNotFoundException, SQLException { | ||
|
||
Properties p = new Properties(); | ||
p.load(new FileInputStream("db.properties")); | ||
Class c = Class.forName(p.getProperty("db.driver")); | ||
System.out.println("Loaded driverClass " + c.getName()); | ||
|
||
Connection con = DriverManager.getConnection( | ||
p.getProperty("db.url"), | ||
"student", "student"); | ||
System.out.println("Got Connection " + con); | ||
|
||
Statement s = con.createStatement(); | ||
int ret; | ||
try { | ||
s.executeUpdate("drop table MR"); | ||
s.executeUpdate("drop type MUSICRECORDING"); | ||
} catch (SQLException andDoNothingWithIt) { | ||
// Should use "if defined" but not sure it works for UDTs... | ||
} | ||
ret = s.executeUpdate( | ||
"create type MUSICRECORDING as object (" + | ||
" id integer," + | ||
" title varchar(20), " + | ||
" artist varchar(20) " + | ||
")"); | ||
System.out.println("Created TYPE! Ret=" + ret); | ||
|
||
ret = s.executeUpdate( | ||
"create table MR of MUSICRECORDING"); | ||
System.out.println("Created TABLE! Ret=" + ret); | ||
|
||
int nRows = s.executeUpdate( | ||
"insert into MR values(123, 'Greatest Hits', 'Ian')"); | ||
System.out.println("inserted " + nRows + " rows"); | ||
|
||
|
||
// Put the data class into the connection's Type Map | ||
// If the data class were not an inner class, | ||
// this would likely be done with Class.forName(...); | ||
Map map = con.getTypeMap(); | ||
map.put("MUSICRECORDING", MusicRecording.class); | ||
con.setTypeMap(map); | ||
|
||
ResultSet rs = s.executeQuery( | ||
"select * from MR where id = 123"); | ||
//"select musicrecording(id,artist,title) from mr"); | ||
rs.next(); | ||
for (int i=1; i<=rs.getMetaData().getColumnCount(); i++) { | ||
Object o = rs.getObject(i); | ||
System.out.print(o + "(Type " + | ||
o.getClass().getName() + ")\t"); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
/** | ||
* Simplified local copy of MusicRecording, so this pgm can stand alone. | ||
* This is an inner class just for illustrative purposes; | ||
* it would normally be an unrelated data class. | ||
*/ | ||
public class MusicRecording { | ||
int id; | ||
String title; | ||
String artist; | ||
public String toString() { | ||
return "MusicRecording#"+id+"["+artist+"--"+title+"]"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# JDBC Properties | ||
|
||
# Connection information for the Oracle database on the server | ||
db.driver = oracle.jdbc.driver.OracleDriver | ||
#db.url = jdbc:oracle:thin:@server:1521:db570 | ||
db.url = jdbc:oracle:thin:@ltree7:1521:db570 | ||
|
||
# Connection information for the Access database on the local machine | ||
# db.driver = sun.jdbc.odbc.JdbcOdbcDriver | ||
# db.url = jdbc:odbc:RainForestDSN | ||
|
||
# userId and password for the database connection | ||
db.user = student | ||
db.password = student |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.