How to use SQLite with Java app .jar file? - java

I'm writing an app that uses SQLite, inside the Netbeans it runsfine, but when I generate a .jar file to use my app it doesn't work. I thought that app will create a db file together (same folder) that .jar file. Only error that I see in the AlertMessage is: ClassNotFound Exception.
private void getConnection() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:Dados");
initialize();
}
EDIT:
I edited the function to:
private void getConnection() {
try {
JOptionPane.showMessageDialog(null, "getConnection() 1");
Class.forName("org.sqlite.JDBC");
JOptionPane.showMessageDialog(null, "getConnection() 2");
con = DriverManager.getConnection("jdbc:sqlite:Dados.db");
JOptionPane.showMessageDialog(null, "getConnection() 3");
initialize();
} catch (Exception e) {
String s = "\nException: " + e.getClass().getName() + "\n";
for(int i = 0; i < e.getStackTrace().length; i++) {
s += e.getStackTrace()[i] + "\n";
}
JOptionPane.showMessageDialog(null, "Error 1: " + s);
}
}
Only "getConnection() 1" is showed. So the error seems to occur in:
Class.forName("org.sqlite.JDBC");
And the error is:
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>ControleMateriais_Maven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<version>3.0.2</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.mycompany.controlemateriais_maven.main.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>

Related

Maven mysql-connector dependency doesnt work

This is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>id</groupId>
<artifactId>jbdc_project</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency>
</dependencies>
</project>
I tried to connect to MySQL database:
public class Main {
public static void main(String[] args) {
String url = "jbdc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false";
String user = "root";
String password = "root";
try{
Connection myConn = DriverManager.getConnection(url,user,password);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
And i get this error:
java.sql.SQLException: No suitable driver found for jbdc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false
Any ideas on how to fix it?
Got it.
There's a typo in your JDBC URL. It should be 'jdbc' instead of 'jbdc'.
String url = "jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false";

import org.neo4j cannot be resolved?

I am very new to Neo4j and I'd like to get started with an embedded Neo4j in a Java Application. I try to run a HelloWorld Application as follows.
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Session;
import org.neo4j.driver.Result;
import org.neo4j.driver.Transaction;
import org.neo4j.driver.TransactionWork;
import static org.neo4j.driver.Values.parameters;
public class HelloWorldExample implements AutoCloseable
{
private final Driver driver;
public HelloWorldExample( String uri, String user, String password )
{
driver = GraphDatabase.driver( uri, AuthTokens.basic( user, password ) );
}
#Override
public void close() throws Exception
{
driver.close();
}
public void printGreeting( final String message )
{
try ( Session session = driver.session() )
{
String greeting = session.writeTransaction( new TransactionWork<String>()
{
#Override
public String execute( Transaction tx )
{
Result result = tx.run( "CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
parameters( "message", message ) );
return result.single().get( 0 ).asString();
}
} );
System.out.println( greeting );
}
}
public static void main( String... args ) throws Exception
{
try ( HelloWorldExample greeter = new HelloWorldExample( "bolt://localhost:7687", "neo4j", "password" ) )
{
greeter.printGreeting( "hello, world" );
}
}
}
The Pom code is as follows.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.0.1</version>
<name>neo4jtest</name>
<build>
<plugins>
<plugin>
<groupId>1</groupId>
<artifactId>2</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>3.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>3.1.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Unfortunately I cannot run the code it raises "Exception in thread "main" java.lang.Error: Unresolved compilation problem: at HelloWorldExample.main(HelloWorldExample.java:46)". Additionally, when hovering over the import lines I see "import org.neo4j cannot be resolved".
Can somebody provide information about this?
As documented, in order to use neo4j's Java driver, you need to specify the appropriate dependency:
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>x.y.z</version>
</dependency>
The latest release version is 4.0.1.
[UPDATE]
Also, your pom.xml file has a lot of other issues. Try something like this instead:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>helloworld</artifactId>
<version>1</version>
<name>neo4jtest</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
</project>
This example POM file uses some dummy groupId, artifactId, and version values for itself (near the top). You should replace them with your own values (not values belonging to neo4j).

The type com.google.cloud.ServiceOptions$Builder cannot be resolved. It is indirectly referenced from required .class files

Here I am trying to insert CSV data into bigQuery table, I already configured google-cloud-bigquery-1.93.0.jar file in eclipse. But I am getting error for "com.google.cloud.ServiceOptions$Builder". see below code which I am using.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.cloud.bigquery.InsertAllResponse;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.InsertAllRequest;
import com.google.cloud.bigquery.InsertAllResponse;
import com.google.cloud.bigquery.TableId;
public class InsertData {
public static void uploaddata(String datasetname) throws IOException {
BigQuery bigquery = BigQueryOptions
.getDefaultInstance()
.toBuilder()
.setProjectId("my-project-id")
.build()
.getService();
TableId tableIdor = TableId.of(datasetname, "table_name");
String csvFile = "D:/my-file/my.csv";
BufferedReader br = null;
FileReader myFile = null;
String line = "";
String cvsSplitBy = ",";
String[] beschriftung = null;
int i = 0;
Map<String, Object> rowContent = new HashMap<>();
myFile = new FileReader(csvFile);
br = new BufferedReader(myFile);
// read CSV file line by line and upload it into BigQuery
while ((line = br.readLine()) != null) {
// get the name of the fields from the first row of the CSV File
if (i == 0) {
beschriftung = line.split(cvsSplitBy);
i = i + 1;
for (int e = 0; e < beschriftung.length; e++) {
rowContent.put(beschriftung[e], "init");
}
} else
// Format Data for BigQuery and upload the row
{
String[] Zeile = line.split(cvsSplitBy);
for (int e = 0; e < Zeile.length; e++) {
rowContent.put(beschriftung[e], Zeile[e]);
}
i = i + 1;
}
InsertAllResponse response = bigquery
.insertAll(InsertAllRequest
.newBuilder(tableIdor)
.addRow(String.valueOf(i), rowContent)
.build());
if (response.hasErrors()) {
System.out.println(response.getErrorsFor(0));
}
}
br.close();
myFile.close();
}
}
I am getting syntax error in below lines.
BigQuery bigquery = BigQueryOptions
.getDefaultInstance()
.toBuilder()
.setProjectId("my-project-id")
Error notification is -
The type com.google.cloud.ServiceOptions$Builder cannot be resolved. It is indirectly referenced from required .class files
=======
pom.xml file
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>insertdata</groupId>
<artifactId>insertdata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>insertdata</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.93.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.90.0</version>
</dependency>
</dependencies>
</project>
Now I am getting below error -
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/cloud/bigquery/BigQueryOptions
at insertdata.insertdata.InsertDataBigQuery.uploaddata(InsertDataBigQuery.java:24)
at insertdata.insertdata.InsertDataBigQuery.main(InsertDataBigQuery.java:78)
Caused by: java.lang.ClassNotFoundException:
com.google.cloud.bigquery.BigQueryOptions
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
What would be the solution, Thanks in advance.
In addition to google-cloud-bigquery-1.93.0.jar, you have to also configure at least google-cloud-core-1.90.0.jar in Eclipse.
BigQueryOptions.getDefaultInstance().toBuilder() returns BigQueryOptions.Builder that extends the missing ServiceOptions.Builder. This is why you get the error.
For all by Google Cloud BigQuery 1.93.0 required dependencies which may require additional dependencies themselves, see section Compile Dependencies in Maven Repository - Google Cloud BigQuery 1.93.0.
Alternatively, you could use a build tool like Maven or Gradle, which will automatically download all necessary dependencies and configure them in Eclipse.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>insertdata</groupId>
<artifactId>insertdata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>insertdata</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.93.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.90.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

How to fix No Manifest Attribute error in maven?

I am trying to use this code below to fix my "Error: No manifest attribute", when I try to run my jar file that has external dependencies instead of it.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
...
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Driver</mainClass>
</manifest>
</archive>
</configuration>
...
</plugin>
</plugins>
However, every time I clean, then compile, then package it and run the jar. It keeps saying:
Error: Could not find or load main class com.harriott.Driver
Caused by: java.lang.ClassNotFoundException: Driver
P.S. I only have one class with a Public static void main method, and it is named Driver:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.harriott</groupId>
<artifactId>UpsDriver</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Driver</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CommonLogging</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CommonsNet</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>cwjcafips</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>cwjssefips</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>MortbayJetty</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>JavaxServlet</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CSPMClient</artifactId>
<version>1.00</version>
</dependency>
</dependencies>
</project>
This is my java code:
import com.cloakware.cspm.client.CSPMClient;
public class Driver {
/**
* Main entry point.
*
* #param "args[0]", String target alias
*
* #param "args[1]", bypass cache flag. If set to:
*
* "true", the cspm client will call the cspm server system
*
* "false", the cspm client will 1st search the local cache
*#param "args[2]", xmlOption. (Optional) If set to:
*
* "-x", Gives the XML data.
* #return int 0 if successful, 100 if an exception ocurred, otherwise
* documented error codes for the CSPMClient class.
*
*/
public static void main(String[] args) {
try {
CSPMClient testInterface = new CSPMClient();
System.out.println("------------------------------------");
System.out.println(testInterface.getAllCredentials());
//System.out.println(testInterface.retrieveCredentials("emc_grab",true));
System.out.println("------------------------------------");
//get the result
String statusCode = testInterface.getStatusCode();
String userId = testInterface.getUserId();
String password = testInterface.getPassword();
String xmlData = testInterface.getXMLData();
System.out.println("Status Code: " + statusCode);
System.out.println("UsedId: " + userId);
System.out.println("Password: " + password);
System.out.println("XML Data: " + xmlData);
//set the return value
if (statusCode.equals("400")) {
System.out.println("PASSED");
System.exit(0);
} else {
System.out.println("FAILED");
System.exit(Integer.parseInt(statusCode));
}
} catch(Exception e) {
e.printStackTrace();
System.exit(100);
}catch(UnsatisfiedLinkError unsatisfiedLinkError){
System.out.println("UnsatisfiedLinkError>>>>");
System.out.println(unsatisfiedLinkError.getMessage());
}
}
}
I will also get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/cloakware/cspm/client/CSPMClient
at Driver.main(Driver.java:29)
Caused by: java.lang.ClassNotFoundException: com.cloakware.cspm.client.CSPMClient
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

How to run web application on hadoop and phoenix

I installed hadoop,hbase and phoenix in ubuntu 14 and runed a simple example for connecting phoenix in eclipse. It's work and execute my query.
public static void execute() throws ClassNotFoundException {
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
PreparedStatement ps = null;
try {
connection = DriverManager.getConnection("jdbc:phoenix:localhost");
statement = connection.createStatement();
// Query for table
ps = connection.prepareStatement("select * from dum.user_info where id=25 ");
rs = ps.executeQuery();
System.out.println("Table Values");
while (rs.next()) {
Integer myKey = rs.getInt(1);
String myColumn = rs.getString(2);
System.out.println("\tRow: " + myKey + " = " + myColumn);
System.out.println("" + rs.getString(3) + " " + rs.getString(4) + " " + rs.getString(5) + " "
+ rs.getString(6) + " " + rs.getString(7));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
Now I'd like to run a web application that connect to phoenix.
I installed tomcat and create a web dynamic application, I can run it and view page in browser but when I add execute function, it doesn't work.
public class LoginServlet extends HttpServlet {
private LoginService userValidationService = new LoginService();
private TodoService todoService = new TodoService();
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try {
phoenixHelper.execute();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(
request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
String password = request.getParameter("password");
boolean isUserValid = userValidationService.isUserValid(name, password);
if (isUserValid) {
request.getSession().setAttribute("name", name);
response.sendRedirect("/list-todos.do");
} else {
request.setAttribute("errorMessage", "Invalid Credentials!");
request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(
request, response);
}
}
}
I faced this error:
java.sql.SQLException: No suitable driver found for jdbc:phoenix:localhost
Can anybody tell me how to run a web application that connect to phoenix?
It's pom.xml.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.in28minutes</groupId>
<artifactId>in28Minutes-first-webapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>4.6.0-HBase-1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<verbose>true</verbose>
<source>1.7</source>
<target>1.7</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.geekcap.javaworld.phoenixexample.PhoenixExample</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Try loading the driver before creating the connection.
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");

Categories

Resources