You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tomcat7-jdbc-jdni-sqlite.md
+37-39Lines changed: 37 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -7,48 +7,46 @@ First download the sqlite jdbc driver from https://bitbucket.org/xerial/sqlite-j
7
7
8
8
Then add a reference to a new jdbc resource in your web/META-INF/context.xml file. It defines a JNDI name, its class type, the driver class name that relates to the jar we just installed above, and a url to connect to the database. In my case I'm pointing to a directory (which must exist) on the file system.
9
9
10
-
<Context>
11
-
<Resource name="jdbc/sqlite"
12
-
type="javax.sql.DataSource"
13
-
driverClassName="org.sqlite.JDBC"
14
-
url="jdbc:sqlite:/var/lib/tomcat7/dbs/test.db"
15
-
>
16
-
</Resource>
17
-
</Context>
10
+
<Context>
11
+
<Resource name="jdbc/sqlite"
12
+
type="javax.sql.DataSource"
13
+
driverClassName="org.sqlite.JDBC"
14
+
url="jdbc:sqlite:/var/lib/tomcat7/dbs/test.db"
15
+
/>
16
+
</Context>
18
17
19
18
In addition, you have to add the resource in your web.xml file. Note the name is the same the name above.
20
19
21
-
...
22
-
<resource-ref>
23
-
<res-ref-name>jdbc/sqlite</res-ref-name>
24
-
<res-type>javax.sql.DataSource</res-type>
25
-
</resource-ref>
26
-
...
20
+
...
21
+
<resource-ref>
22
+
<res-ref-name>jdbc/sqlite</res-ref-name>
23
+
<res-type>javax.sql.DataSource</res-type>
24
+
</resource-ref>
25
+
...
27
26
28
27
Now you can make reference to the database in your Java code. This is lifted from the sqlite example page:
0 commit comments