Advertisement
Guest User

Untitled

a guest
Apr 7th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.88 KB | None | 0 0
  1. package activejdbc.examples.simple;
  2.  
  3. import org.javalite.activejdbc.Base;
  4. import org.javalite.activejdbc.DB;
  5. import org.postgresql.Driver;
  6.  
  7. public class Main {
  8.  
  9. public static void main(String[] args) {
  10. try {
  11.  
  12. System.out.println(Class.forName("org.postgresql.Driver"));
  13.  
  14.  
  15. } catch (ClassNotFoundException e) {
  16.  
  17. System.out.println("Where is your PostgreSQL JDBC Driver? "
  18. + "Include in your library path!");
  19. e.printStackTrace();
  20. return;
  21.  
  22. }
  23. Base.open("org.postgresql.Driver", "jdbc:postgresql://<ip>:<port>/<database_name>", "<database_user>", "<password>");
  24.  
  25. Person director = new Person();
  26. director.set("name", "Steven Spielberg");
  27. director.saveIt();
  28.  
  29. director.add(new Movie("Saving private Ryan", 1998));
  30. director.add(new Movie("Jaws", 1982));
  31. director.getAll(Movie.class).forEach(System.out::println);
  32.  
  33. Base.close();
  34. }
  35. }
  36.  
  37. Connected to the target VM, address: '127.0.0.1:42363', transport: 'socket'
  38. class org.postgresql.Driver
  39. Exception in thread "main" org.javalite.activejdbc.InitException: java.lang.NullPointerException
  40. at org.javalite.activejdbc.Registry.init(Registry.java:154)
  41. at org.javalite.activejdbc.Registry.getMetaModel(Registry.java:103)
  42. at org.javalite.activejdbc.ModelDelegate.metaModelOf(ModelDelegate.java:289)
  43. at org.javalite.activejdbc.Model.<init>(Model.java:79)
  44. at activejdbc.examples.simple.Person.<init>(Person.java:10)
  45. at activejdbc.examples.simple.Main.main(Main.java:25)
  46. Caused by: java.lang.NullPointerException
  47. at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getColumns(AbstractJdbc2DatabaseMetaData.java:2502)
  48. at org.postgresql.jdbc4.AbstractJdbc4DatabaseMetaData.getColumns(AbstractJdbc4DatabaseMetaData.java:99)
  49. at org.javalite.activejdbc.Registry.fetchMetaParams(Registry.java:198)
  50. at org.javalite.activejdbc.Registry.init(Registry.java:138)
  51. ... 5 more
  52. Disconnected from the target VM, address: '127.0.0.1:42363', transport: 'socket'
  53.  
  54. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  55. <modelVersion>4.0.0</modelVersion>
  56. <groupId>com.heroku.sample</groupId>
  57. <artifactId>webappRunnerSample</artifactId>
  58. <version>1.0-SNAPSHOT</version>
  59. <name>webappRunnerSample Maven Webapp</name>
  60. <packaging>war</packaging>
  61. <url>http://maven.apache.org</url>
  62. <properties>
  63. <activejdbc.version>2.1-SNAPSHOT</activejdbc.version>
  64. <environments>development.test,development</environments>
  65. </properties>
  66. <build>
  67. <finalName>webappRunnerSample</finalName>
  68. <plugins>
  69. <plugin>
  70. <groupId>org.apache.maven.plugins</groupId>
  71. <artifactId>maven-compiler-plugin</artifactId>
  72. <version>3.6.0</version>
  73. <configuration>
  74. <source>1.8</source>
  75. <target>1.8</target>
  76. <encoding>UTF-8</encoding>
  77. </configuration>
  78. </plugin>
  79. <plugin>
  80. <groupId>org.javalite</groupId>
  81. <artifactId>activejdbc-instrumentation</artifactId>
  82. <version>2.0</version>
  83. <executions>
  84. <execution>
  85. <phase>process-classes</phase>
  86. <goals>
  87. <goal>instrument</goal>
  88. </goals>
  89. </execution>
  90. </executions>
  91. </plugin>
  92. <plugin>
  93. <groupId>org.javalite</groupId>
  94. <artifactId>db-migrator-maven-plugin</artifactId>
  95. <version>2.0</version>
  96. <configuration>
  97. <configFile>
  98. ${project.basedir}/src/main/resources/database.properties
  99. </configFile>
  100. <environments>${environments}</environments>
  101. </configuration>
  102. <executions>
  103. <execution>
  104. <id>dev_migrations</id>
  105. <phase>validate</phase>
  106. <goals>
  107. <goal>migrate</goal>
  108. </goals>
  109. </execution>
  110. </executions>
  111. <dependencies>
  112. <dependency>
  113. <groupId>postgresql</groupId>
  114. <artifactId>postgresql</artifactId>
  115. <version>9.1-901-1.jdbc4</version>
  116. </dependency>
  117. <dependency>
  118. <groupId>mysql</groupId>
  119. <artifactId>mysql-connector-java</artifactId>
  120. <version>5.1.34</version>
  121. </dependency>
  122. </dependencies>
  123. </plugin>
  124. <plugin>
  125. <groupId>org.apache.maven.plugins</groupId>
  126. <artifactId>maven-surefire-plugin</artifactId>
  127. <version>2.18.1</version>
  128. <configuration>
  129. <reportFormat>brief</reportFormat>
  130. <trimStackTrace>true</trimStackTrace>
  131. <useFile>false</useFile>
  132. <includes>
  133. <include>**/*Spec*.java</include>
  134. <include>**/*Test*.java</include>
  135. </includes>
  136. <excludes>
  137. <exclude>**/helpers/*</exclude>
  138. <exclude>**/*$*</exclude>
  139. </excludes>
  140.  
  141. </configuration>
  142. </plugin>
  143. <plugin>
  144. <groupId>org.apache.maven.plugins</groupId>
  145. <artifactId>maven-dependency-plugin</artifactId>
  146. <version>2.3</version>
  147. <executions>
  148. <execution>
  149. <phase>package</phase>
  150. <goals>
  151. <goal>copy</goal>
  152. </goals>
  153. <configuration>
  154. <artifactItems>
  155. <artifactItem>
  156. <groupId>com.github.jsimone</groupId>
  157. <artifactId>webapp-runner</artifactId>
  158. <version>7.0.22</version>
  159. <destFileName>webapp-runner.jar</destFileName>
  160. </artifactItem>
  161. </artifactItems>
  162. </configuration>
  163. </execution>
  164. </executions>
  165. </plugin>
  166. </plugins>
  167. </build>
  168. <dependencies>
  169. <dependency>
  170. <groupId>junit</groupId>
  171. <artifactId>junit</artifactId>
  172. <version>4.12</version>
  173. <scope>test</scope>
  174. </dependency>
  175. <dependency>
  176. <groupId>org.javalite</groupId>
  177. <artifactId>activejdbc</artifactId>
  178. <version>2.0</version>
  179. <exclusions>
  180. <exclusion>
  181. <groupId>opensymphony</groupId>
  182. <artifactId>oscache</artifactId>
  183. </exclusion>
  184. </exclusions>
  185. </dependency>
  186. <dependency>
  187. <groupId>postgresql</groupId>
  188. <artifactId>postgresql</artifactId>
  189. <version>9.1-901-1.jdbc4</version>
  190. </dependency>
  191. <dependency>
  192. <groupId>mysql</groupId>
  193. <artifactId>mysql-connector-java</artifactId>
  194. <version>5.1.34</version>
  195. </dependency>
  196. <dependency>
  197. <groupId>org.slf4j</groupId>
  198. <artifactId>slf4j-simple</artifactId>
  199. <version>1.8.0-beta1</version>
  200. </dependency>
  201. <dependency>
  202. <groupId>org.codehaus.groovy</groupId>
  203. <artifactId>groovy</artifactId>
  204. <version>1.8.3</version>
  205. <scope>test</scope>
  206. </dependency>
  207. <dependency>
  208. <groupId>ch.qos.logback</groupId>
  209. <artifactId>logback-classic</artifactId>
  210. <version>1.2.3</version>
  211. </dependency>
  212. <dependency>
  213. <groupId>org.glassfish.jersey.containers</groupId>
  214. <artifactId>jersey-container-servlet</artifactId>
  215. <version>2.25.1</version>
  216. </dependency>
  217.  
  218. <dependency>
  219. <groupId>org.glassfish</groupId>
  220. <artifactId>javax.json</artifactId>
  221. <version>1.0.2</version>
  222. </dependency>
  223.  
  224. <dependency>
  225. <groupId>javax.servlet</groupId>
  226. <artifactId>servlet-api</artifactId>
  227. <version>2.5</version>
  228. <scope>provided</scope>
  229. </dependency>
  230.  
  231. <dependency>
  232. <groupId>com.sun.xml.ws</groupId>
  233. <artifactId>jaxws-rt</artifactId>
  234. <version>2.2.8</version>
  235. </dependency>
  236. <dependency>
  237. <groupId>com.sun.xml.bind</groupId>
  238. <artifactId>jaxb-core</artifactId>
  239. <version>2.2.7</version>
  240. </dependency>
  241. <dependency>
  242. <groupId>com.sun.xml.stream.buffer</groupId>
  243. <artifactId>streambuffer</artifactId>
  244. <version>1.5.3</version>
  245. </dependency>
  246. <dependency>
  247. <groupId>com.sun.xml.bind</groupId>
  248. <artifactId>jaxb-impl</artifactId>
  249. <version>2.2.7</version>
  250. </dependency>
  251. <dependency>
  252. <groupId>com.sun.xml.ws</groupId>
  253. <artifactId>policy</artifactId>
  254. <version>2.3.1</version>
  255. </dependency>
  256. <dependency>
  257. <groupId>org.glassfish.gmbal</groupId>
  258. <artifactId>gmbal-api-only</artifactId>
  259. <version>3.2.0-b003</version>
  260. </dependency>
  261. <dependency>
  262. <groupId>org.glassfish.ha</groupId>
  263. <artifactId>ha-api</artifactId>
  264. <version>3.1.9</version>
  265. </dependency>
  266. </dependencies>
  267. <repositories>
  268. <repository>
  269. <id>snapshots1</id>
  270. <name>JavaLite Snapshots1</name>
  271. <url>http://repo.javalite.io/</url>
  272. <snapshots>
  273. <enabled>true</enabled>
  274. <updatePolicy>always</updatePolicy>
  275. <checksumPolicy>warn</checksumPolicy>
  276. </snapshots>
  277. </repository>
  278. </repositories>
  279. <pluginRepositories>
  280. <pluginRepository>
  281. <id>snapshots2</id>
  282. <name>JavaLite Snapshots2</name>
  283. <url>http://repo.javalite.io/</url>
  284. <snapshots>
  285. <enabled>true</enabled>
  286. <updatePolicy>always</updatePolicy>
  287. <checksumPolicy>warn</checksumPolicy>
  288. </snapshots>
  289. </pluginRepository>
  290. </pluginRepositories>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement