phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Di Spaltro <dan.dispal...@gmail.com>
Subject Re: Can't connect to Phoenix via JDBC in Scala
Date Mon, 01 Sep 2014 03:18:09 GMT
I've used scalikeJDBC [1] pretty successful with Phoenix.  I had to add
some special sauce for upserts vs inserts, but it's a pretty light wrapper
and works well.  I think I use a code block like this in my bootstrapping
flow:

DriverManager.registerDriver(PhoenixDriver.INSTANCE)

[1] http://scalikejdbc.org/




On Fri, Aug 29, 2014 at 12:03 PM, Samarth Jain <samarth.jain@gmail.com>
wrote:

> Hi Russell,
>
> I am not a Scala guy, but do you know if calling classOf[com.salesforce.phoenix.jdbc.PhoenixDriver]
> ends up loading the java class and hence executing the static block? If it
> doesn't you might want to try DriverManager.registerDriver(
> com.salesforce.phoenix.jdbc.PhoenixDriver) and then try getting a
> connection using DriverManager.getConnection(url).
>
> - Samarth
>
>
> On Fri, Aug 29, 2014 at 11:46 AM, Russell Jurney <russell.jurney@gmail.com
> > wrote:
>
>> I'm having trouble connecting to Phoenix 2.2.2 from scala. What am I
>> doing wrong?
>>
>>
>> [hivedata@hivedev1 phoenix-debug]$ scala -classpath
>> lib/phoenix-2.2.2.jar
>> Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java
>> 1.7.0_51).
>> Type in expressions to have them evaluated.
>> Type :help for more information.
>>
>> scala> import java.sql.{Connection, DriverManager, ResultSet};
>> import java.sql.{Connection, DriverManager, ResultSet}
>>
>> scala> import com.salesforce.phoenix.jdbc.PhoenixDriver
>> import com.salesforce.phoenix.jdbc.PhoenixDriver
>>
>> scala>
>>
>> scala> classOf[com.salesforce.phoenix.jdbc.PhoenixDriver]
>> res0: Class[com.salesforce.phoenix.jdbc.PhoenixDriver] = class
>> com.salesforce.phoenix.jdbc.PhoenixDriver
>>
>> scala> val conn_str = "jdbc:phoenix:hiveapp2"
>> conn_str: String = jdbc:phoenix:hiveapp2
>>
>> scala>
>>
>> scala> val conn = DriverManager.getConnection(conn_str)
>> java.sql.SQLException: No suitable driver found for jdbc:phoenix:hiveapp2
>> at java.sql.DriverManager.getConnection(DriverManager.java:596)
>> at java.sql.DriverManager.getConnection(DriverManager.java:233)
>> at .<init>(<console>:10)
>> at .<clinit>(<console>)
>> at .<init>(<console>:7)
>> at .<clinit>(<console>)
>> at $print(<console>)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
>> at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
>> at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
>> at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
>> at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
>> at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:760)
>> at
>> scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:805)
>> at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:717)
>> at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:581)
>> at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:588)
>> at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:591)
>> at
>> scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:882)
>> at
>> scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
>> at
>> scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
>> at
>> scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
>> at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:837)
>> at
>> scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
>> at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
>> at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
>>
>> at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
>>
>> --
>> Russell Jurney twitter.com/rjurney russell.jurney@gmail.com datasyndrome.
>> com
>>
>>
>


-- 
Dan Di Spaltro

Mime
View raw message