Support Questions

Find answers, ask questions, and share your expertise

How to import all tables from SQL server to Hive

Explorer

Hi

Please Provide the solution for Importing all tables from SQL to hive

6 REPLIES 6

Explorer

Hi

I have a Query like this,

sqoop import --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --connect “jdbc:sqlserver://XX.XX.XXX:1433; database=PTWTarget” --username sa --P --table ActionItems --create-hive-tables --target-dir /sqltohive/actionitems --hive-import -m 1

when i execute, i'm getting error in TCP/IP connection had refused.

Mentor

@Nethaji R

When you are running the sqoop command for importing all tables ie the whole database then you shouldn't have

[--table ] parameter in your command they are mutually exclusive.

Sqoop will assume your destination database will have the same name as the source

sqoop import-all-tables --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver \
--connect jdbc:sqlserver://XX.XX.XXX:1433; database=PTWTarget \
--username username \
--password password -- \
--schema the_schema \
--hive-database PTWTarget --hive-import

HTH

Explorer

sqoop import-all-tables --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --connect jdbc:sqlserver://XX.XX.XXX:1433; database=PTWTarget --username ML_Testing --password Admin --hive-database PTWTarget --hive-import

I tried like this but i'm getting error, please validate my code and provide me solution

Error: java.lang.RuntimeException: java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host x.x.x.x, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

Mentor

@Nethaji R

The default database port for sql server is 1433 can you validate that the hostname and port are correct from your DBA or Firewall setting block your node/IP ?

Can you add quotes like below note the single quote and removal of space between the port1433 and database. copy and pas to see if that works

sqoop import-all-tables --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --connect 'jdbc:sqlserver://XX.XX.XXX:1433;database=PTWTarget' --username 'ML_Testing' --password 'Admin' --hive-database PTWTarget --hive-import

HTH

Mentor

@Nethaji R

Any updates did my response resolve the issue or answer your question if so accept so the thread is marked as closed.